From a0632f7753509cb703b377dcdeb625d1b3fd9348 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 22 Feb 2021 17:22:30 +0100 Subject: [PATCH] automation module --- app/build.gradle | 1 + app/src/main/AndroidManifest.xml | 3 - .../dependencyInjection/AppComponent.kt | 1 + .../dependencyInjection/AppModule.kt | 8 ++ .../androidaps/dialogs/WizardDialog.kt | 2 +- .../historyBrowser/HistoryBrowseActivity.kt | 2 +- .../androidaps/plugins/aps/loop/LoopPlugin.kt | 14 +- .../dataBroadcaster/DataBroadcastPlugin.kt | 2 +- .../general/overview/OverviewFragment.kt | 4 +- .../notifications/NotificationStore.kt | 7 +- .../notifications/NotificationWithAction.kt | 1 + .../PersistentNotificationPlugin.kt | 10 +- .../smsCommunicator/SmsCommunicatorPlugin.kt | 4 +- .../general/wear/ActionStringHandler.kt | 2 +- .../plugins/general/wear/WearPlugin.kt | 2 +- .../xdripStatusline/StatusLinePlugin.kt | 2 +- .../IobCobCalculatorPlugin.kt | 10 +- .../iob/iobCobCalculator/IobCobOref1Thread.kt | 6 +- .../iob/iobCobCalculator/IobCobThread.kt | 4 +- .../fragments/TreatmentsBolusFragment.kt | 2 +- .../TreatmentsExtendedBolusesFragment.kt | 2 +- .../TreatmentsTemporaryBasalsFragment.kt | 2 +- .../androidNotification/NotificationHolder.kt | 16 ++- .../androidNotification/NotificationUtils.kt | 13 -- .../utils/resources/IconsProvider.kt | 9 +- .../utils/wizard/QuickWizardEntry.kt | 2 +- app/src/main/res/values-it-rIT/strings.xml | 1 - app/src/main/res/values-sv-rSE/strings.xml | 1 - app/src/main/res/values/arrays.xml | 12 -- app/src/main/res/values/colors.xml | 8 -- app/src/main/res/values/strings.xml | 136 ------------------ automation/.gitignore | 1 + automation/build.gradle | 21 +++ automation/consumer-rules.pro | 0 automation/proguard-rules.pro | 21 +++ automation/src/main/AndroidManifest.xml | 13 ++ .../automation/di}/AutomationModule.kt | 4 +- .../androidaps/events/EventLocationChange.kt | 0 .../general/automation/AutomationEvent.kt | 0 .../general/automation/AutomationFragment.kt | 6 +- .../general/automation/AutomationPlugin.kt | 21 ++- .../general/automation/actions/Action.kt | 0 .../general/automation/actions/ActionAlarm.kt | 2 +- .../general/automation/actions/ActionDummy.kt | 0 .../automation/actions/ActionLoopDisable.kt | 15 +- .../automation/actions/ActionLoopEnable.kt | 15 +- .../automation/actions/ActionLoopResume.kt | 10 +- .../automation/actions/ActionLoopSuspend.kt | 6 +- .../automation/actions/ActionNotification.kt | 3 +- .../automation/actions/ActionProfileSwitch.kt | 2 +- .../actions/ActionProfileSwitchPercent.kt | 2 +- .../automation/actions/ActionSendSMS.kt | 6 +- .../actions/ActionStartTempTarget.kt | 2 +- .../actions/ActionStopTempTarget.kt | 2 +- .../automation/dialogs/ChooseActionDialog.kt | 10 +- .../automation/dialogs/ChooseTriggerDialog.kt | 8 +- .../automation/dialogs/EditActionDialog.kt | 8 +- .../automation/dialogs/EditEventDialog.kt | 4 +- .../automation/dialogs/EditTriggerDialog.kt | 2 +- .../dragHelpers/ItemTouchHelperAdapter.kt | 0 .../dragHelpers/ItemTouchHelperViewHolder.kt | 0 .../dragHelpers/OnStartDragListener.kt | 0 .../SimpleItemTouchHelperCallback.kt | 0 .../general/automation/elements/Comparator.kt | 2 +- .../automation/elements/ComparatorConnect.kt | 2 +- .../automation/elements/ComparatorExists.kt | 2 +- .../general/automation/elements/Element.kt | 0 .../general/automation/elements/InputBg.kt | 2 +- .../automation/elements/InputButton.kt | 0 .../automation/elements/InputDateTime.kt | 4 +- .../general/automation/elements/InputDelta.kt | 2 +- .../automation/elements/InputDouble.kt | 2 +- .../automation/elements/InputDropdownMenu.kt | 4 +- .../automation/elements/InputDuration.kt | 2 +- .../automation/elements/InputInsulin.kt | 2 +- .../automation/elements/InputLocationMode.kt | 2 +- .../automation/elements/InputPercent.kt | 2 +- .../automation/elements/InputProfileName.kt | 2 +- .../automation/elements/InputString.kt | 0 .../automation/elements/InputTempTarget.kt | 2 +- .../general/automation/elements/InputTime.kt | 2 +- .../automation/elements/InputTimeRange.kt | 2 +- .../automation/elements/InputWeekDay.kt | 2 +- .../automation/elements/LabelWithElement.kt | 0 .../automation/elements/LayoutBuilder.kt | 0 .../automation/elements/StaticLabel.kt | 0 .../events/EventAutomationAddAction.kt | 0 .../events/EventAutomationDataChanged.kt | 0 .../events/EventAutomationUpdateAction.kt | 0 .../events/EventAutomationUpdateGui.kt | 0 .../events/EventAutomationUpdateTrigger.kt | 0 .../automation/events/EventTriggerChanged.kt | 0 .../automation/events/EventTriggerClone.kt | 0 .../automation/events/EventTriggerRemove.kt | 0 .../general/automation/triggers/Trigger.kt | 16 +-- .../triggers/TriggerAutosensValue.kt | 4 +- .../automation/triggers/TriggerBTDevice.kt | 2 +- .../general/automation/triggers/TriggerBg.kt | 2 +- .../automation/triggers/TriggerBolusAgo.kt | 2 +- .../general/automation/triggers/TriggerCOB.kt | 4 +- .../automation/triggers/TriggerConnector.kt | 2 +- .../automation/triggers/TriggerDelta.kt | 2 +- .../automation/triggers/TriggerDummy.kt | 0 .../general/automation/triggers/TriggerIob.kt | 2 +- .../automation/triggers/TriggerLocation.kt | 2 +- .../triggers/TriggerProfilePercent.kt | 2 +- .../triggers/TriggerPumpLastConnection.kt | 3 +- .../triggers/TriggerRecurringTime.kt | 2 +- .../automation/triggers/TriggerTempTarget.kt | 2 +- .../automation/triggers/TriggerTime.kt | 4 +- .../automation/triggers/TriggerTimeRange.kt | 4 +- .../automation/triggers/TriggerWifiSsid.kt | 4 +- .../services/LastLocationDataContainer.kt | 0 .../androidaps/services/LocationService.kt | 6 +- .../services/LocationServiceHelper.kt | 0 .../res/drawable/border_automation_unit.xml | 0 .../res/drawable/ic_action_orange_48dp.xml | 0 .../main/res/drawable/ic_add_black_24dp.xml | 0 .../drawable/ic_arrow_forward_white_24dp.xml | 0 .../src/main/res/drawable/ic_as.xml | 0 .../src/main/res/drawable/ic_auto_delta.xml | 0 .../src/main/res/drawable/ic_automation.xml | 0 .../res/drawable/ic_keyboard_capslock.xml | 0 .../src/main/res/drawable/ic_keyboard_tab.xml | 0 .../src/main/res/drawable/ic_location_on.xml | 0 .../src/main/res/drawable/ic_network_wifi.xml | 0 .../main/res/drawable/ic_notifications.xml | 0 .../drawable/ic_pause_circle_outline_24dp.xml | 0 .../drawable/ic_play_circle_outline_24dp.xml | 0 .../res/drawable/ic_reorder_gray_24dp.xml | 0 .../src/main/res/drawable/ic_replay_24dp.xml | 0 .../src/main/res/drawable/ic_stop_24dp.xml | 0 .../res/drawable/ic_trigger_green_48dp.xml | 0 .../res/layout/automation_action_item.xml | 0 .../res/layout/automation_dialog_action.xml | 0 .../automation_dialog_choose_action.xml | 0 .../automation_dialog_choose_trigger.xml | 0 .../layout/automation_dialog_edit_trigger.xml | 0 .../res/layout/automation_dialog_event.xml | 0 .../main/res/layout/automation_event_item.xml | 0 .../main/res/layout/automation_fragment.xml | 0 automation/src/main/res/values/arrays.xml | 15 ++ automation/src/main/res/values/strings.xml | 114 +++++++++++++++ .../src/main/res/xml/pref_automation.xml | 0 .../general/automation/AutomationEventTest.kt | 10 +- .../general/automation/ComposeTriggerTest.kt | 0 .../plugins/general/automation/TestBase.kt | 40 ++++++ .../general/automation/TestBaseWithProfile.kt | 82 +++++++++++ .../general/automation/TestPumpPlugin.kt | 79 ++++++++++ .../automation/actions/ActionAlarmTest.kt | 2 +- .../actions/ActionLoopDisableTest.kt | 15 +- .../actions/ActionLoopEnableTest.kt | 16 +-- .../actions/ActionLoopResumeTest.kt | 3 +- .../actions/ActionLoopSuspendTest.kt | 4 +- .../actions/ActionNotificationTest.kt | 2 +- .../actions/ActionProfileSwitchPercentTest.kt | 2 +- .../actions/ActionProfileSwitchTest.kt | 11 +- .../automation/actions/ActionSendSMSTest.kt | 4 +- .../actions/ActionStartTempTargetTest.kt | 5 +- .../actions/ActionStopTempTargetTest.kt | 5 +- .../general/automation/actions/ActionTest.kt | 0 .../automation/actions/ActionsTestBase.kt | 46 ++++-- .../elements/ComparatorConnectTest.kt | 0 .../elements/ComparatorExistsTest.kt | 0 .../automation/elements/ComparatorTest.kt | 0 .../automation/elements/InputBgTest.kt | 0 .../automation/elements/InputDurationTest.kt | 0 .../automation/elements/InputInsulinTest.kt | 0 .../automation/elements/InputPercentTest.kt | 0 .../elements/InputProfileNameTest.kt | 0 .../automation/elements/InputStringTest.kt | 0 .../elements/InputTempTargetTest.kt | 0 .../elements/LabelWithElementTest.kt | 0 .../automation/elements/LayoutBuilderTest.kt | 0 .../automation/elements/StaticLabelTest.kt | 2 +- .../automation/triggers/DummyTrigger.kt | 0 .../triggers/TriggerAutosensValueTest.kt | 5 +- .../triggers/TriggerBTDeviceTest.kt | 2 +- .../automation/triggers/TriggerBgTest.kt | 5 +- .../triggers/TriggerBolusAgoTest.kt | 5 +- .../automation/triggers/TriggerCOBTest.kt | 5 +- .../triggers/TriggerConnectorTest.kt | 0 .../automation/triggers/TriggerDeltaTest.kt | 5 +- .../automation/triggers/TriggerIobTest.kt | 5 +- .../triggers/TriggerLocationTest.kt | 2 +- .../triggers/TriggerProfilePercentTest.kt | 2 +- .../triggers/TriggerPumpLastConnectionTest.kt | 11 +- .../triggers/TriggerRecurringTimeTest.kt | 0 .../triggers/TriggerTempTargetTest.kt | 5 +- .../automation/triggers/TriggerTestBase.kt | 14 +- .../triggers/TriggerTimeRangeTest.kt | 2 +- .../automation/triggers/TriggerTimeTest.kt | 2 +- .../triggers/TriggerWifiSsidTest.kt | 2 +- .../core/ExampleInstrumentedTest.kt | 25 ---- .../dialogs/DialogFragmentWithDate.kt | 2 +- .../EventAutosensCalculationFinished.kt | 2 +- .../interfaces/IconsProviderInterface.kt | 6 + .../interfaces/IobCobCalculatorInterface.java | 14 -- .../interfaces/IobCobCalculatorInterface.kt | 22 +++ .../androidaps/interfaces/LoopInterface.kt | 5 + .../interfaces/NotificationHolderInterface.kt | 3 + .../androidaps/interfaces/PluginBase.kt | 2 +- .../interfaces/SmsCommunicatorInterface.kt | 6 + .../notifications/NotificationUserMessage.kt | 0 .../notifications/NotificationWithAction.kt | 2 + .../plugins/iob/iobCobCalculator/CobInfo.kt | 0 .../iob/iobCobCalculator/GlucoseStatus.kt | 3 +- .../androidaps/utils/MidnightTime.java | 0 .../nightscout/androidaps/utils/TimerUtil.kt | 2 +- .../res/drawable/ic_access_alarm_24dp.xml | 0 .../src/main/res/drawable/ic_add.xml | 0 .../src/main/res/drawable/ic_bolus.xml | 0 .../src/main/res/drawable/ic_clone.xml | 0 .../src/main/res/drawable/ic_cp_bgcheck.xml | 0 .../main/res/drawable/ic_cp_bolus_carbs.xml | 0 .../src/main/res/drawable/ic_notif_aaps.xml | 0 .../src/main/res/drawable/ic_remove.xml | 0 .../main/res/drawable/ic_temptarget_high.xml | 0 .../src/main/res/layout/datetime.xml | 0 {app => core}/src/main/res/layout/notes.xml | 0 core/src/main/res/values/colors.xml | 7 + core/src/main/res/values/strings.xml | 27 ++++ crowdin.yml | 2 + settings.gradle | 1 + 224 files changed, 746 insertions(+), 490 deletions(-) delete mode 100644 app/src/main/java/info/nightscout/androidaps/utils/androidNotification/NotificationUtils.kt create mode 100644 automation/.gitignore create mode 100644 automation/build.gradle create mode 100644 automation/consumer-rules.pro create mode 100644 automation/proguard-rules.pro create mode 100644 automation/src/main/AndroidManifest.xml rename {app/src/main/java/info/nightscout/androidaps/dependencyInjection => automation/src/main/java/info/nightscout/androidaps/automation/di}/AutomationModule.kt (96%) rename {app => automation}/src/main/java/info/nightscout/androidaps/events/EventLocationChange.kt (100%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationEvent.kt (100%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationFragment.kt (98%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationPlugin.kt (95%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/Action.kt (100%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionAlarm.kt (98%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionDummy.kt (100%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopDisable.kt (76%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopEnable.kt (74%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopResume.kt (83%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopSuspend.kt (94%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionNotification.kt (98%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitch.kt (98%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchPercent.kt (98%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionSendSMS.kt (91%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStartTempTarget.kt (98%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStopTempTarget.kt (96%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/ChooseActionDialog.kt (92%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/ChooseTriggerDialog.kt (92%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/EditActionDialog.kt (91%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/EditEventDialog.kt (98%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/EditTriggerDialog.kt (97%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/dragHelpers/ItemTouchHelperAdapter.kt (100%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/dragHelpers/ItemTouchHelperViewHolder.kt (100%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/dragHelpers/OnStartDragListener.kt (100%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/dragHelpers/SimpleItemTouchHelperCallback.kt (100%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/Comparator.kt (98%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/ComparatorConnect.kt (98%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/ComparatorExists.kt (97%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/Element.kt (100%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputBg.kt (97%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputButton.kt (100%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDateTime.kt (96%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDelta.kt (98%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDouble.kt (97%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDropdownMenu.kt (93%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDuration.kt (97%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputInsulin.kt (94%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputLocationMode.kt (98%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputPercent.kt (95%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputProfileName.kt (97%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputString.kt (100%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTempTarget.kt (97%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTime.kt (98%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTimeRange.kt (98%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputWeekDay.kt (98%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/LabelWithElement.kt (100%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/LayoutBuilder.kt (100%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/StaticLabel.kt (100%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/events/EventAutomationAddAction.kt (100%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/events/EventAutomationDataChanged.kt (100%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/events/EventAutomationUpdateAction.kt (100%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/events/EventAutomationUpdateGui.kt (100%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/events/EventAutomationUpdateTrigger.kt (100%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/events/EventTriggerChanged.kt (100%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/events/EventTriggerClone.kt (100%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/events/EventTriggerRemove.kt (100%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/Trigger.kt (93%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerAutosensValue.kt (98%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBTDevice.kt (98%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBg.kt (98%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBolusAgo.kt (98%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerCOB.kt (96%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerConnector.kt (99%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerDelta.kt (99%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerDummy.kt (100%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerIob.kt (98%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerLocation.kt (99%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerProfilePercent.kt (98%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerPumpLastConnection.kt (98%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTime.kt (98%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTempTarget.kt (98%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTime.kt (93%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeRange.kt (95%) rename {app => automation}/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerWifiSsid.kt (95%) rename {app => automation}/src/main/java/info/nightscout/androidaps/services/LastLocationDataContainer.kt (100%) rename {app => automation}/src/main/java/info/nightscout/androidaps/services/LocationService.kt (97%) rename {app => automation}/src/main/java/info/nightscout/androidaps/services/LocationServiceHelper.kt (100%) rename {app => automation}/src/main/res/drawable/border_automation_unit.xml (100%) rename {app => automation}/src/main/res/drawable/ic_action_orange_48dp.xml (100%) rename {app => automation}/src/main/res/drawable/ic_add_black_24dp.xml (100%) rename {app => automation}/src/main/res/drawable/ic_arrow_forward_white_24dp.xml (100%) rename {app => automation}/src/main/res/drawable/ic_as.xml (100%) rename {app => automation}/src/main/res/drawable/ic_auto_delta.xml (100%) rename {app => automation}/src/main/res/drawable/ic_automation.xml (100%) rename {app => automation}/src/main/res/drawable/ic_keyboard_capslock.xml (100%) rename {app => automation}/src/main/res/drawable/ic_keyboard_tab.xml (100%) rename {app => automation}/src/main/res/drawable/ic_location_on.xml (100%) rename {app => automation}/src/main/res/drawable/ic_network_wifi.xml (100%) rename {app => automation}/src/main/res/drawable/ic_notifications.xml (100%) rename {app => automation}/src/main/res/drawable/ic_pause_circle_outline_24dp.xml (100%) rename {app => automation}/src/main/res/drawable/ic_play_circle_outline_24dp.xml (100%) rename {app => automation}/src/main/res/drawable/ic_reorder_gray_24dp.xml (100%) rename {app => automation}/src/main/res/drawable/ic_replay_24dp.xml (100%) rename {app => automation}/src/main/res/drawable/ic_stop_24dp.xml (100%) rename {app => automation}/src/main/res/drawable/ic_trigger_green_48dp.xml (100%) rename {app => automation}/src/main/res/layout/automation_action_item.xml (100%) rename {app => automation}/src/main/res/layout/automation_dialog_action.xml (100%) rename {app => automation}/src/main/res/layout/automation_dialog_choose_action.xml (100%) rename {app => automation}/src/main/res/layout/automation_dialog_choose_trigger.xml (100%) rename {app => automation}/src/main/res/layout/automation_dialog_edit_trigger.xml (100%) rename {app => automation}/src/main/res/layout/automation_dialog_event.xml (100%) rename {app => automation}/src/main/res/layout/automation_event_item.xml (100%) rename {app => automation}/src/main/res/layout/automation_fragment.xml (100%) create mode 100644 automation/src/main/res/values/arrays.xml create mode 100644 automation/src/main/res/values/strings.xml rename {app => automation}/src/main/res/xml/pref_automation.xml (100%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/AutomationEventTest.kt (89%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/ComposeTriggerTest.kt (100%) create mode 100644 automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/TestBase.kt create mode 100644 automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/TestBaseWithProfile.kt create mode 100644 automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/TestPumpPlugin.kt rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionAlarmTest.kt (98%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopDisableTest.kt (75%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopEnableTest.kt (70%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopResumeTest.kt (94%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopSuspendTest.kt (92%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionNotificationTest.kt (98%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchPercentTest.kt (98%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchTest.kt (88%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionSendSMSTest.kt (95%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStartTempTargetTest.kt (93%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStopTempTargetTest.kt (90%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionTest.kt (100%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionsTestBase.kt (68%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/ComparatorConnectTest.kt (100%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/ComparatorExistsTest.kt (100%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/ComparatorTest.kt (100%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/InputBgTest.kt (100%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDurationTest.kt (100%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/InputInsulinTest.kt (100%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/InputPercentTest.kt (100%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/InputProfileNameTest.kt (100%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/InputStringTest.kt (100%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTempTargetTest.kt (100%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/LabelWithElementTest.kt (100%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/LayoutBuilderTest.kt (100%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/StaticLabelTest.kt (94%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/DummyTrigger.kt (100%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerAutosensValueTest.kt (96%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBTDeviceTest.kt (97%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBgTest.kt (95%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBolusAgoTest.kt (96%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerCOBTest.kt (94%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerConnectorTest.kt (100%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerDeltaTest.kt (97%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerIobTest.kt (95%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerLocationTest.kt (99%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerProfilePercentTest.kt (98%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerPumpLastConnectionTest.kt (89%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTimeTest.kt (100%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTempTargetTest.kt (94%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTestBase.kt (84%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeRangeTest.kt (98%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeTest.kt (98%) rename {app => automation}/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerWifiSsidTest.kt (98%) delete mode 100644 core/src/androidTest/java/info/nightscout/androidaps/core/ExampleInstrumentedTest.kt rename {app => core}/src/main/java/info/nightscout/androidaps/dialogs/DialogFragmentWithDate.kt (99%) rename {app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator => core/src/main/java/info/nightscout/androidaps}/events/EventAutosensCalculationFinished.kt (70%) create mode 100644 core/src/main/java/info/nightscout/androidaps/interfaces/IconsProviderInterface.kt delete mode 100644 core/src/main/java/info/nightscout/androidaps/interfaces/IobCobCalculatorInterface.java create mode 100644 core/src/main/java/info/nightscout/androidaps/interfaces/IobCobCalculatorInterface.kt create mode 100644 core/src/main/java/info/nightscout/androidaps/interfaces/SmsCommunicatorInterface.kt rename {app => core}/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationUserMessage.kt (100%) create mode 100644 core/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationWithAction.kt rename {app => core}/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/CobInfo.kt (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/GlucoseStatus.kt (98%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/MidnightTime.java (100%) rename {app => core}/src/main/java/info/nightscout/androidaps/utils/TimerUtil.kt (95%) rename {app => core}/src/main/res/drawable/ic_access_alarm_24dp.xml (100%) rename {app => core}/src/main/res/drawable/ic_add.xml (100%) rename {app => core}/src/main/res/drawable/ic_bolus.xml (100%) rename {app => core}/src/main/res/drawable/ic_clone.xml (100%) rename {app => core}/src/main/res/drawable/ic_cp_bgcheck.xml (100%) rename {app => core}/src/main/res/drawable/ic_cp_bolus_carbs.xml (100%) rename {app => core}/src/main/res/drawable/ic_notif_aaps.xml (100%) rename {app => core}/src/main/res/drawable/ic_remove.xml (100%) rename {app => core}/src/main/res/drawable/ic_temptarget_high.xml (100%) rename {app => core}/src/main/res/layout/datetime.xml (100%) rename {app => core}/src/main/res/layout/notes.xml (100%) diff --git a/app/build.gradle b/app/build.gradle index 889521cc89..91496e7627 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -177,6 +177,7 @@ dependencies { wearApp project(':wear') implementation project(':core') + implementation project(':automation') implementation project(':combo') implementation project(':database') implementation project(':dana') diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a367417120..18750bfda8 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -140,9 +140,6 @@ android:resource="@xml/filepaths" /> - diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppComponent.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppComponent.kt index f1075e2e9c..d431be7a6c 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppComponent.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppComponent.kt @@ -5,6 +5,7 @@ import dagger.Component import dagger.android.AndroidInjectionModule import dagger.android.AndroidInjector import info.nightscout.androidaps.MainApp +import info.nightscout.androidaps.automation.di.AutomationModule import info.nightscout.androidaps.combo.di.ComboModule import info.nightscout.androidaps.core.di.CoreModule import info.nightscout.androidaps.dana.di.DanaModule diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt index e807a8d7f7..72c9ad308b 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt @@ -10,13 +10,17 @@ import info.nightscout.androidaps.Config import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.db.DatabaseHelperProvider import info.nightscout.androidaps.interfaces.* +import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin import info.nightscout.androidaps.plugins.configBuilder.PluginStore import info.nightscout.androidaps.plugins.general.maintenance.ImportExportPrefs import info.nightscout.androidaps.plugins.general.nsclient.UploadQueue +import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin +import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin import info.nightscout.androidaps.queue.CommandQueue import info.nightscout.androidaps.utils.androidNotification.NotificationHolder +import info.nightscout.androidaps.utils.resources.IconsProvider import info.nightscout.androidaps.utils.rx.AapsSchedulers import info.nightscout.androidaps.utils.rx.DefaultAapsSchedulers import info.nightscout.androidaps.utils.storage.FileStorage @@ -66,5 +70,9 @@ open class AppModule { @Binds fun bindUploadQueueInterface(uploadQueue: UploadQueue): UploadQueueInterface @Binds fun bindNotificationHolderInterface(notificationHolder: NotificationHolder): NotificationHolderInterface @Binds fun bindImportExportPrefsInterface(importExportPrefs: ImportExportPrefs): ImportExportPrefsInterface + @Binds fun bindIconsProviderInterface(iconsProvider: IconsProvider): IconsProviderInterface + @Binds fun bindLoopInterface(loopPlugin: LoopPlugin): LoopInterface + @Binds fun bindIobCobCalculatorInterface(iobCobCalculatorPlugin: IobCobCalculatorPlugin): IobCobCalculatorInterface + @Binds fun bindSmsCommunicatorInterface(smsCommunicatorPlugin: SmsCommunicatorPlugin): SmsCommunicatorInterface } } diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/WizardDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/WizardDialog.kt index 543e38ddcb..fae30fc39a 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/WizardDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/WizardDialog.kt @@ -28,7 +28,7 @@ import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished +import info.nightscout.androidaps.events.EventAutosensCalculationFinished import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin import info.nightscout.androidaps.utils.DecimalFormatter import info.nightscout.androidaps.utils.FabricPrivacy diff --git a/app/src/main/java/info/nightscout/androidaps/historyBrowser/HistoryBrowseActivity.kt b/app/src/main/java/info/nightscout/androidaps/historyBrowser/HistoryBrowseActivity.kt index c99616c7fc..8ee346247e 100644 --- a/app/src/main/java/info/nightscout/androidaps/historyBrowser/HistoryBrowseActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/historyBrowser/HistoryBrowseActivity.kt @@ -24,7 +24,7 @@ import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.overview.OverviewMenus import info.nightscout.androidaps.plugins.general.overview.graphData.GraphData import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensBgLoaded -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished +import info.nightscout.androidaps.events.EventAutosensCalculationFinished import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.DefaultValueHelper 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 74ca108a37..e02d1f5935 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 @@ -35,7 +35,7 @@ import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotifi import info.nightscout.androidaps.plugins.general.overview.notifications.Notification import info.nightscout.androidaps.plugins.general.wear.events.EventWearDoAction import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished +import info.nightscout.androidaps.events.EventAutosensCalculationFinished import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin import info.nightscout.androidaps.queue.Callback @@ -58,7 +58,7 @@ import kotlin.math.abs @Singleton open class LoopPlugin @Inject constructor( injector: HasAndroidInjector, - aapsLogger: AAPSLogger?, + aapsLogger: AAPSLogger, private val aapsSchedulers: AapsSchedulers, private val rxBus: RxBusWrapper, private val sp: SP, @@ -85,7 +85,7 @@ open class LoopPlugin @Inject constructor( .preferencesId(R.xml.pref_loop) .enableByDefault(config.APS) .description(R.string.description_loop), - aapsLogger!!, resourceHelper, injector + aapsLogger, resourceHelper, injector ), LoopInterface { private val disposable = CompositeDisposable() @@ -147,7 +147,7 @@ open class LoopPlugin @Inject constructor( } } - fun suspendTo(endTime: Long) { + override fun suspendTo(endTime: Long) { sp.putLong("loopSuspendedTill", endTime) sp.putBoolean("isSuperBolus", false) sp.putBoolean("isDisconnected", false) @@ -178,7 +178,7 @@ open class LoopPlugin @Inject constructor( } // time exceeded - val isSuspended: Boolean + override val isSuspended: Boolean get() { val loopSuspendedTill = sp.getLong("loopSuspendedTill", 0L) if (loopSuspendedTill == 0L) return false @@ -638,7 +638,7 @@ open class LoopPlugin @Inject constructor( createOfflineEvent(durationInMinutes) } - fun suspendLoop(durationInMinutes: Int) { + override fun suspendLoop(durationInMinutes: Int) { suspendTo(System.currentTimeMillis() + durationInMinutes * 60 * 1000) commandQueue.cancelTempBasal(true, object : Callback() { override fun run() { @@ -650,7 +650,7 @@ open class LoopPlugin @Inject constructor( createOfflineEvent(durationInMinutes) } - fun createOfflineEvent(durationInMinutes: Int) { + override fun createOfflineEvent(durationInMinutes: Int) { val data = JSONObject() try { data.put("eventType", CareportalEvent.OPENAPSOFFLINE) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/dataBroadcaster/DataBroadcastPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/dataBroadcaster/DataBroadcastPlugin.kt index 85b557b925..7ab5c30703 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/dataBroadcaster/DataBroadcastPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/dataBroadcaster/DataBroadcastPlugin.kt @@ -23,7 +23,7 @@ import info.nightscout.androidaps.plugins.general.nsclient.data.NSDeviceStatus import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished +import info.nightscout.androidaps.events.EventAutosensCalculationFinished import info.nightscout.androidaps.receivers.ReceiverStatusStore import info.nightscout.androidaps.services.Intents import info.nightscout.androidaps.utils.DefaultValueHelper 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 7dd0ea848a..3066532b14 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 @@ -46,7 +46,7 @@ import info.nightscout.androidaps.plugins.general.overview.notifications.Notific import info.nightscout.androidaps.plugins.general.wear.events.EventWearDoAction import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished +import info.nightscout.androidaps.events.EventAutosensCalculationFinished import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress import info.nightscout.androidaps.plugins.pump.common.defs.PumpType import info.nightscout.androidaps.plugins.source.DexcomPlugin @@ -764,7 +764,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList var cobText: String = resourceHelper.gs(R.string.value_unavailable_short) val cobInfo = iobCobCalculatorPlugin.getCobInfo(false, "Overview COB") if (cobInfo.displayCob != null) { - cobText = resourceHelper.gs(R.string.format_carbs, cobInfo.displayCob.toInt()) + cobText = resourceHelper.gs(R.string.format_carbs, cobInfo.displayCob!!.toInt()) if (cobInfo.futureCarbs > 0) cobText += "(" + DecimalFormatter.to0Decimal(cobInfo.futureCarbs) + ")" } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationStore.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationStore.kt index e818dd8fc1..2e791771f6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationStore.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationStore.kt @@ -14,13 +14,13 @@ import androidx.core.app.NotificationCompat import androidx.recyclerview.widget.RecyclerView import info.nightscout.androidaps.R import info.nightscout.androidaps.databinding.OverviewNotificationItemBinding +import info.nightscout.androidaps.interfaces.NotificationHolderInterface import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification import info.nightscout.androidaps.services.AlarmSoundServiceHelper import info.nightscout.androidaps.utils.DateUtil -import info.nightscout.androidaps.utils.androidNotification.openAppIntent import info.nightscout.androidaps.utils.resources.IconsProvider import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP @@ -37,7 +37,8 @@ class NotificationStore @Inject constructor( private val context: Context, private val iconsProvider: IconsProvider, private val alarmSoundServiceHelper: AlarmSoundServiceHelper, - private val dateUtil: DateUtil + private val dateUtil: DateUtil, + private val notificationHolder: NotificationHolderInterface ) { private var store: MutableList = ArrayList() @@ -112,7 +113,7 @@ class NotificationStore @Inject constructor( .setStyle(NotificationCompat.BigTextStyle().bigText(n.text)) .setPriority(NotificationCompat.PRIORITY_MAX) .setDeleteIntent(deleteIntent(n.id)) - .setContentIntent(openAppIntent(context)) + .setContentIntent(notificationHolder.openAppIntent(context)) if (n.level == Notification.URGENT) { notificationBuilder.setVibrate(longArrayOf(1000, 1000, 1000, 1000)) .setContentTitle(resourceHelper.gs(R.string.urgent_alarm)) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationWithAction.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationWithAction.kt index 4e85b03b5c..e254278fd4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationWithAction.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationWithAction.kt @@ -12,6 +12,7 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP import javax.inject.Inject +@Suppress("SpellCheckingInspection") class NotificationWithAction constructor( injector: HasAndroidInjector ) : Notification() { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/persistentNotification/PersistentNotificationPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/persistentNotification/PersistentNotificationPlugin.kt index d65114f9ff..f770689e37 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/persistentNotification/PersistentNotificationPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/persistentNotification/PersistentNotificationPlugin.kt @@ -17,11 +17,8 @@ import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished import info.nightscout.androidaps.utils.DecimalFormatter import info.nightscout.androidaps.utils.FabricPrivacy -import info.nightscout.androidaps.utils.androidNotification.NotificationHolder -import info.nightscout.androidaps.utils.androidNotification.openAppIntent import info.nightscout.androidaps.utils.resources.IconsProvider import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.rx.AapsSchedulers @@ -43,10 +40,9 @@ class PersistentNotificationPlugin @Inject constructor( private val iobCobCalculatorPlugin: IobCobCalculatorPlugin, private val rxBus: RxBusWrapper, private val context: Context, - private val notificationHolder: NotificationHolder, + private val notificationHolder: NotificationHolderInterface, private val dummyServiceHelper: DummyServiceHelper, - private val iconsProvider: IconsProvider, - private val databaseHelper: DatabaseHelperInterface + private val iconsProvider: IconsProvider ) : PluginBase(PluginDescription() .mainType(PluginType.GENERAL) .neverVisible(true) @@ -216,7 +212,7 @@ class PersistentNotificationPlugin @Inject constructor( .setUnreadConversation(unreadConversationBuilder.build())) } /// End Android Auto - builder.setContentIntent(openAppIntent(context)) + builder.setContentIntent(notificationHolder.openAppIntent(context)) val mNotificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager val notification = builder.build() mNotificationManager.notify(notificationHolder.notificationID, notification) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt index c44460c604..5673dfedcf 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt @@ -80,7 +80,7 @@ class SmsCommunicatorPlugin @Inject constructor( .preferencesId(R.xml.pref_smscommunicator) .description(R.string.description_sms_communicator), aapsLogger, resourceHelper, injector -) { +), SmsCommunicatorInterface { private val disposable = CompositeDisposable() var allowedNumbers: MutableList = ArrayList() @@ -998,7 +998,7 @@ class SmsCommunicatorPlugin @Inject constructor( } else sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat))) } - fun sendNotificationToAllNumbers(text: String): Boolean { + override fun sendNotificationToAllNumbers(text: String): Boolean { var result = true for (i in allowedNumbers.indices) { val sms = Sms(allowedNumbers[i], text) 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 2fbdbe6360..51846f1270 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 @@ -204,7 +204,7 @@ class ActionStringHandler @Inject constructor( val format = DecimalFormat("0.00") val formatInt = DecimalFormat("0") val bolusWizard = BolusWizard(injector).doCalc(profile, profileName, activePlugin.activeTreatments.tempTargetFromHistory, - carbsAfterConstraints, cobInfo.displayCob, bgReading.valueToUnits(profileFunction.getUnits()), + carbsAfterConstraints, if (cobInfo.displayCob != null) cobInfo.displayCob!! else 0.0, bgReading.valueToUnits(profileFunction.getUnits()), 0.0, percentage.toDouble(), useBG, useCOB, useBolusIOB, useBasalIOB, false, useTT, useTrend, false) if (Math.abs(bolusWizard.insulinAfterConstraints - bolusWizard.calculatedTotalInsulin) >= 0.01) { sendError("Insulin constraint violation!" + diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/WearPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/WearPlugin.kt index 84acfc5667..f3cdd7a7f2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/WearPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/WearPlugin.kt @@ -16,7 +16,7 @@ import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.overview.events.EventDismissBolusProgressIfRunning import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress import info.nightscout.androidaps.plugins.general.wear.wearintegration.WatchUpdaterService -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished +import info.nightscout.androidaps.events.EventAutosensCalculationFinished import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.rx.AapsSchedulers diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/xdripStatusline/StatusLinePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/xdripStatusline/StatusLinePlugin.kt index 7dd387b89a..a705394f59 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/xdripStatusline/StatusLinePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/xdripStatusline/StatusLinePlugin.kt @@ -16,7 +16,7 @@ import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished +import info.nightscout.androidaps.events.EventAutosensCalculationFinished import info.nightscout.androidaps.utils.DecimalFormatter import info.nightscout.androidaps.utils.FabricPrivacy import io.reactivex.rxkotlin.plusAssign diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.kt index de1c931ccb..1009972939 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.kt @@ -71,14 +71,14 @@ open class IobCobCalculatorPlugin @Inject constructor( private var absIobTable = LongSparseArray() // oldest at index 0, absolute insulin in the body private var autosensDataTable = LongSparseArray() // oldest at index 0 private var basalDataTable = LongSparseArray() // oldest at index 0 - @Volatile var bgReadings: List = listOf() // newest at index 0 + @Volatile override var bgReadings: List = listOf() // newest at index 0 @Volatile var bucketedData: MutableList? = null // we need to make sure that bucketed_data will always have the same timestamp for correct use of cached values // once referenceTime != null all bucketed data should be (x * 5min) from referenceTime var referenceTime: Long = -1 private var lastUsed5minCalculation: Boolean? = null // true if used 5min bucketed data - val dataLock = Any() + override val dataLock = Any() var stopCalculationTrigger = false private var thread: Thread? = null @@ -388,7 +388,7 @@ open class IobCobCalculatorPlugin @Inject constructor( return getBGDataFrom } - fun calculateFromTreatmentsAndTempsSynchronized(time: Long, profile: Profile?): IobTotal { + override fun calculateFromTreatmentsAndTempsSynchronized(time: Long, profile: Profile?): IobTotal { synchronized(dataLock) { return calculateFromTreatmentsAndTemps(time, profile) } } @@ -524,7 +524,7 @@ open class IobCobCalculatorPlugin @Inject constructor( synchronized(dataLock) { return getLastAutosensData(reason) } } - fun getCobInfo(_synchronized: Boolean, reason: String): CobInfo { + override fun getCobInfo(_synchronized: Boolean, reason: String): CobInfo { val autosensData = if (_synchronized) getLastAutosensDataSynchronized(reason) else getLastAutosensData(reason) var displayCob: Double? = null var futureCarbs = 0.0 @@ -563,7 +563,7 @@ open class IobCobCalculatorPlugin @Inject constructor( return sum / count } - fun getLastAutosensData(reason: String): AutosensData? { + override fun getLastAutosensData(reason: String): AutosensData? { if (autosensDataTable.size() < 1) { aapsLogger.debug(LTag.AUTOSENS, "AUTOSENSDATA null: autosensDataTable empty ($reason)") return null diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobOref1Thread.kt b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobOref1Thread.kt index 5bb64109ae..f03314829d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobOref1Thread.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobOref1Thread.kt @@ -17,7 +17,7 @@ import info.nightscout.androidaps.plugins.general.overview.notifications.Notific import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin.Companion.roundUpTime import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensBgLoaded -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished +import info.nightscout.androidaps.events.EventAutosensCalculationFinished import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin @@ -82,7 +82,7 @@ class IobCobOref1Thread internal constructor( rxBus.send(EventAutosensBgLoaded(cause)) } val bucketedData = iobCobCalculatorPlugin.bucketedData - val autosensDataTable = iobCobCalculatorPlugin.autosensDataTable + val autosensDataTable = iobCobCalculatorPlugin.getAutosensDataTable() if (bucketedData == null || bucketedData.size < 3) { aapsLogger.debug(LTag.AUTOSENS, "Aborting calculation thread (No bucketed data available): $from") return @@ -288,7 +288,7 @@ class IobCobOref1Thread internal constructor( } } - // add an extra negative deviation if a high temptarget is running and exercise mode is set + // add an extra negative deviation if a high temp target is running and exercise mode is set // TODO AS-FIX @Suppress("SimplifyBooleanWithConstants") if (false && sp.getBoolean(R.string.key_high_temptarget_raises_sensitivity, SMBDefaults.high_temptarget_raises_sensitivity)) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobThread.kt b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobThread.kt index 1f67032978..ed5af41c6d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobThread.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobThread.kt @@ -18,7 +18,7 @@ import info.nightscout.androidaps.plugins.general.overview.notifications.Notific import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin.Companion.roundUpTime import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensBgLoaded -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished +import info.nightscout.androidaps.events.EventAutosensCalculationFinished import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin @@ -83,7 +83,7 @@ class IobCobThread @Inject internal constructor( rxBus.send(EventAutosensBgLoaded(cause)) } val bucketedData = iobCobCalculatorPlugin.bucketedData - val autosensDataTable = iobCobCalculatorPlugin.autosensDataTable + val autosensDataTable = iobCobCalculatorPlugin.getAutosensDataTable() if (bucketedData == null || bucketedData.size < 3) { aapsLogger.debug(LTag.AUTOSENS, "Aborting calculation thread (No bucketed data available): $from") return diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusFragment.kt index d830ca5414..6c399ed374 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusFragment.kt @@ -21,7 +21,7 @@ import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import info.nightscout.androidaps.plugins.general.nsclient.UploadQueue import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientRestart -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished +import info.nightscout.androidaps.events.EventAutosensCalculationFinished import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin import info.nightscout.androidaps.plugins.treatments.fragments.TreatmentsBolusFragment.RecyclerViewAdapter.TreatmentsViewHolder import info.nightscout.androidaps.utils.DateUtil diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsExtendedBolusesFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsExtendedBolusesFragment.kt index e223fd150a..20e41bb406 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsExtendedBolusesFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsExtendedBolusesFragment.kt @@ -24,7 +24,7 @@ import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import info.nightscout.androidaps.plugins.general.nsclient.UploadQueue -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished +import info.nightscout.androidaps.events.EventAutosensCalculationFinished import info.nightscout.androidaps.plugins.treatments.fragments.TreatmentsExtendedBolusesFragment.RecyclerViewAdapter.ExtendedBolusesViewHolder import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.FabricPrivacy diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTemporaryBasalsFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTemporaryBasalsFragment.kt index b17933471c..f9d1004d1b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTemporaryBasalsFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTemporaryBasalsFragment.kt @@ -22,7 +22,7 @@ import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.nsclient.NSUpload -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished +import info.nightscout.androidaps.events.EventAutosensCalculationFinished import info.nightscout.androidaps.plugins.treatments.fragments.TreatmentsTemporaryBasalsFragment.RecyclerViewAdapter.TempBasalsViewHolder import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.FabricPrivacy diff --git a/app/src/main/java/info/nightscout/androidaps/utils/androidNotification/NotificationHolder.kt b/app/src/main/java/info/nightscout/androidaps/utils/androidNotification/NotificationHolder.kt index 77df9dbc69..72dbb6430f 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/androidNotification/NotificationHolder.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/androidNotification/NotificationHolder.kt @@ -2,11 +2,15 @@ package info.nightscout.androidaps.utils.androidNotification import android.app.Notification import android.app.NotificationManager +import android.app.PendingIntent import android.content.Context +import android.content.Intent import androidx.core.app.NotificationCompat -import info.nightscout.androidaps.R +import androidx.core.app.TaskStackBuilder +import info.nightscout.androidaps.MainActivity +import info.nightscout.androidaps.core.R +import info.nightscout.androidaps.interfaces.IconsProviderInterface import info.nightscout.androidaps.interfaces.NotificationHolderInterface -import info.nightscout.androidaps.utils.resources.IconsProvider import info.nightscout.androidaps.utils.resources.ResourceHelper import javax.inject.Inject import javax.inject.Singleton @@ -15,7 +19,7 @@ import javax.inject.Singleton class NotificationHolder @Inject constructor( resourceHelper: ResourceHelper, context: Context, - iconsProvider: IconsProvider + iconsProvider: IconsProviderInterface ) : NotificationHolderInterface { override val channelID = "AndroidAPS-Ongoing" @@ -32,4 +36,10 @@ class NotificationHolder @Inject constructor( .also { (context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager).notify(notificationID, it) } + + override fun openAppIntent(context: Context): PendingIntent? = TaskStackBuilder.create(context).run { + addParentStack(MainActivity::class.java) + addNextIntent(Intent(context, MainActivity::class.java)) + getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT) + } } diff --git a/app/src/main/java/info/nightscout/androidaps/utils/androidNotification/NotificationUtils.kt b/app/src/main/java/info/nightscout/androidaps/utils/androidNotification/NotificationUtils.kt deleted file mode 100644 index 26787bd135..0000000000 --- a/app/src/main/java/info/nightscout/androidaps/utils/androidNotification/NotificationUtils.kt +++ /dev/null @@ -1,13 +0,0 @@ -package info.nightscout.androidaps.utils.androidNotification - -import android.app.PendingIntent -import android.content.Context -import android.content.Intent -import androidx.core.app.TaskStackBuilder -import info.nightscout.androidaps.MainActivity - -fun openAppIntent(context: Context): PendingIntent? = TaskStackBuilder.create(context).run { - addParentStack(MainActivity::class.java) - addNextIntent(Intent(context, MainActivity::class.java)) - getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT) -} \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/utils/resources/IconsProvider.kt b/app/src/main/java/info/nightscout/androidaps/utils/resources/IconsProvider.kt index 6bdeaa73a8..beab1f4330 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/resources/IconsProvider.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/resources/IconsProvider.kt @@ -1,21 +1,22 @@ package info.nightscout.androidaps.utils.resources -import info.nightscout.androidaps.Config import info.nightscout.androidaps.R +import info.nightscout.androidaps.interfaces.ConfigInterface +import info.nightscout.androidaps.interfaces.IconsProviderInterface import javax.inject.Inject import javax.inject.Singleton @Singleton -class IconsProvider @Inject constructor(private val config: Config) { +class IconsProvider @Inject constructor(private val config: ConfigInterface) : IconsProviderInterface { - fun getIcon(): Int = + override fun getIcon(): Int = when { config.NSCLIENT -> R.mipmap.ic_yellowowl config.PUMPCONTROL -> R.mipmap.ic_pumpcontrol else -> R.mipmap.ic_launcher } - fun getNotificationIcon(): Int = + override fun getNotificationIcon(): Int = when { config.NSCLIENT -> R.drawable.ic_notif_nsclient config.PUMPCONTROL -> R.drawable.ic_notif_pumpcontrol diff --git a/app/src/main/java/info/nightscout/androidaps/utils/wizard/QuickWizardEntry.kt b/app/src/main/java/info/nightscout/androidaps/utils/wizard/QuickWizardEntry.kt index 39da06c1f5..4cc4047dbf 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/wizard/QuickWizardEntry.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/wizard/QuickWizardEntry.kt @@ -83,7 +83,7 @@ class QuickWizardEntry @Inject constructor(private val injector: HasAndroidInjec var cob = 0.0 if (useCOB() == YES) { val cobInfo = iobCobCalculatorPlugin.getCobInfo(_synchronized, "QuickWizard COB") - if (cobInfo.displayCob != null) cob = cobInfo.displayCob + if (cobInfo.displayCob != null) cob = cobInfo.displayCob!! } // Bolus IOB var bolusIOB = false diff --git a/app/src/main/res/values-it-rIT/strings.xml b/app/src/main/res/values-it-rIT/strings.xml index 8bfdf04a07..481fdd0af4 100644 --- a/app/src/main/res/values-it-rIT/strings.xml +++ b/app/src/main/res/values-it-rIT/strings.xml @@ -699,7 +699,6 @@ Terzo incremento di CHO CGM Usa solo connessione WiFi - WiFi SSID Solo se in carica Impostazioni connessione SSID ammessi (separati da punto e virgola) diff --git a/app/src/main/res/values-sv-rSE/strings.xml b/app/src/main/res/values-sv-rSE/strings.xml index 779fc8bcc4..9c45b4092d 100644 --- a/app/src/main/res/values-sv-rSE/strings.xml +++ b/app/src/main/res/values-sv-rSE/strings.xml @@ -78,7 +78,6 @@ Eversense-appen. Ingen BG-data tillänglig Beräknat behov Glukos - Delta Delta: Konfigurationsverktyg Översikt diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index ecffee5c8e..622de5d371 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -87,18 +87,6 @@ @string/key_pregnant - - @string/use_passive_location - @string/use_network_location - @string/use_gps_location - - - - PASSIVE - NETWORK - GPS - - Generic AAPS Accu-Chek Spirit diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 573c94c900..bb0bdaa8c1 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -26,7 +26,6 @@ #B3FFFFFF #77dd77 - #77dd77 #67DFE8 @@ -51,18 +50,11 @@ #ff827c #009705 - #66000000 #c8666666 #7200FF00 #72FF0000 #72000000 - #5a595b - #f4d700 - #ff0400 - #FFFFFF - #303030 - #2E2E2E diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f4d5bb15d3..b0e5102919 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -102,7 +102,6 @@ Result: %1$s %2$s No glucose data available Request - Glucose Delta Delta: @@ -155,8 +154,6 @@ Open Loop Low Glucose Suspend Loop Disabled - Disable loop - Enable loop New suggestion available Carbs Suggestion @@ -170,11 +167,8 @@ Sensor Carb time Duration - Notes - Event time Profile Glucose type - No profile loaded from NS yet TempBasal Extended Bolus Nightscout version: @@ -239,7 +233,6 @@ Allow remote commands via SMS Loop has been disabled Loop has been enabled - Loop is disabled Loop is enabled %1$.2f limited to %2$.2f Value %1$s is out of hard limits @@ -281,7 +274,6 @@ Valid: Add Edit - Remove Meal Corr Actions @@ -315,8 +307,6 @@ %1$dmin ago Local Profile OpenAPS AMA - Short avg. delta - Long avg. delta Array of %1$d elements.\nActual value: Autosens data Script debug @@ -326,7 +316,6 @@ Eating Soon Hypo Activity - Remove record ACT CONF LOOP @@ -345,9 +334,7 @@ Profile Default value: 3 This is a key OpenAPS safety cap. What this does is limit your basals to be 3x (in this people) your biggest basal rate. You likely will not need to change this, but you should be aware that’s what is discussed about “3x max daily; 4x current” for safety caps. Default value: 4 This is the other half of the key OpenAPS safety caps, and the other half of “3x max daily; 4x current” of the safety caps. This means your basal, regardless of max basal set on your pump, cannot be any higher than this number times the current level of your basal. This is to prevent people from getting into dangerous territory by setting excessively high max basals before understanding how the algorithm works. Again, the default is 4x; most people will never need to adjust this and are instead more likely to need to adjust other settings if they feel like they are “running into” this safety cap. - autosens_max Default value: 1.2\nThis is a multiplier cap for autosens (and soon autotune) to set a 20%% max limit on how high the autosens ratio can be, which in turn determines how high autosens can adjust basals, how low it can adjust ISF, and how low it can set the BG target. - autosens_min Default value: 0.7\nThe other side of the autosens safety limits, putting a cap on how low autosens can adjust basals, and how high it can adjust ISF and BG targets. autosens_adjust_targets Autosens adjust targets, too @@ -419,12 +406,10 @@ %1$s needs battery optimalization whitelisting for proper performance Loop suspended Suspended (%1$d m) - Suspend loop Suspend loop for 1h Suspend loop for 2h Suspend loop for 3h Suspend loop for 10 h - Suspend loop for %1$d min Disconnect pump Disconnect pump for 15 min Disconnect pump for 30 min @@ -485,8 +470,6 @@ statuslights_bat_critical Threshold critical pump battery level [%] PRED - IOB - COB BAS DEV ACT @@ -551,7 +534,6 @@ Values not stored! Enable broadcasts to other apps (like xDrip+). Do not enable if you have more than one instance of AAPS or NSClient installed! Enable local Broadcasts. - Duration [min] OpenAPS SMB use_smb use_uam @@ -739,7 +721,6 @@ Limiting IOB to %1$.1f U because of %2$s max value in preferences hard limit - treatmentssafety_maxcarbs openapsama_useautosens Read status failed Record pump site change @@ -754,8 +735,6 @@ This value is called Max IOB in OpenAPS context\nOpenAPS will not add more insulin if current IOB is greater than this value Meal max absorption time [h] Time at which any meal is considered absorbed. Remaining carbs will be cut off. - Time - show_notes_entry_dialogs Show notes field in treatment dialogs SetupWizardActivity Next @@ -878,46 +857,6 @@ Minimal request change [%] Open Loop will popup new change request only if change is bigger than this value in %. Default value is 20% short_tabtitles - Sun - Sat - Fri - Thu - Wed - Tue - Mon - User defined automation tasks - Please enter a task name. - Please specify at least one trigger. - Please specify at least one action. - Already enabled - Already disabled - Already suspended - Resume loop - Not suspended - Start temp target - Stop temp target - is lesser than - is equal or lesser than - is equal to - is equal or greater than - is greater than - is not available - Glucose is not available - Glucose %1$s %2$.0f %3$s - Glucose %1$s %2$.1f %3$s - Profile pct %1$s %2$d - IOB %1$s %2$.1f - And - Or - Exclusive or - At %1$s - Use network location - Use GPS location - Use passive location - Location service - location - Auto - Automation == ∑ %1$s U dexcom_lognssensorchange @@ -966,17 +905,6 @@ Wrong code. Command cancelled. Not configured Profile switch created - Recurring time - Every - Never - Condition: - Action: - IOB [U]: - Glucose [%1$s]: - DEL - ADD - COPY - Add new Version Checker old version @@ -988,71 +916,13 @@ DXCM Receive BG values from the patched Dexcom app. - Notification - Notification: %1$s - Alarm: %1$s - Msg: - Alarm: - Profile percentage - Percent [%]: - Start profile %1$d%% for %2$d min - Start profile %1$d%% - exists - not exists - Temp target %1$s - Bluetooth connection to device %1$s %2$s - Connection to Bluetooth device - WiFi SSID %1$s %2$s - Autosens %1$s %2$s %% - Autosens % - %3$s %1$s %2$s - BG difference - BG difference [%1$s] - Current Location - Location - Lat: - Lon: - Dist [m]: - Name: - %1$s %2$s - When - When you are inside the area - When you are outside the area - When you enter the area named - When you leave the area named - Last bolus ago - Last bolus time %1$s %2$s min ago - COB - COB %1$s %2$.0f - Task name - EDIT - Choose an action type - Choose a trigger type - Triggers: - REMOVE - Preconditions: - - Change profile to - Change profile to %1$s - Last connection to pump - Last connection to pump [minutes ago] - Last connection to pump %1$s %2$s min ago - Send SMS: %1$s - Send SMS to all numbers - Send SMS with text - - COB vs IOB Bolus constraint applied: %1$.2f U to %2$.2f U !!!!! Slow carbs absorption detected: %2$d%% of time. Double check your calculation. COB can be overestimated thus more insulin could be given !!!!!]]> boluswizard_percentage Deliver this part of bolus wizard result [%] Bolus wizard performs calculation but only this part of calculated insulin is delivered. Useful with SMB algorithm. - Loading ... Snooze - Time range - Time is between %1$s and %2$s - Between Increasing max basal value because setting is lower than your max basal in profile Invalid message body @@ -1085,7 +955,6 @@ Profile name contains dots.\nThis is not supported by NS.\nProfile is not uploaded to NS. Lower value of in range area (display only) Higher value of in range area (display only) - Reorder Age: Weight: @@ -1107,8 +976,6 @@ BG Tools Show calcuation - Automation event - Already set Clear queue? All data in queue will be lost! xdripstatus_detailediob xdripstatus_showbgi @@ -1157,8 +1024,6 @@ On each follower phone install Authenticator app that support RFC 6238 TOTP tokens. Popular free apps are:\n • Authy\n • Google Authenticator\n • LastPass Authenticator\n • FreeOTP Authenticator By reseting authenticator you make all already provisioned authenticators invalid. You will need to set up them again! - On connect - On disconnect Predictions Deviation slope graphconfig @@ -1224,7 +1089,6 @@ Filter Unable to create local profile. Profile is invalid. Don\'t kill my app? - Alarm smscommunicator_report_pump_ureachable Send SMS if unreachable pump event is triggered Report pump unreachable diff --git a/automation/.gitignore b/automation/.gitignore new file mode 100644 index 0000000000..42afabfd2a --- /dev/null +++ b/automation/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/automation/build.gradle b/automation/build.gradle new file mode 100644 index 0000000000..55565f892b --- /dev/null +++ b/automation/build.gradle @@ -0,0 +1,21 @@ +apply plugin: 'com.android.library' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-kapt' +apply plugin: 'com.hiya.jacoco-android' + +apply from: "${project.rootDir}/gradle/android_dependencies.gradle" +apply from: "${project.rootDir}/gradle/android_module_dependencies.gradle" +apply from: "${project.rootDir}/gradle/test_dependencies.gradle" + + +android { + defaultConfig { + versionCode 1 + versionName "1.0" + } +} + +dependencies { + implementation project(':core') + implementation project(':database') +} \ No newline at end of file diff --git a/automation/consumer-rules.pro b/automation/consumer-rules.pro new file mode 100644 index 0000000000..e69de29bb2 diff --git a/automation/proguard-rules.pro b/automation/proguard-rules.pro new file mode 100644 index 0000000000..481bb43481 --- /dev/null +++ b/automation/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/automation/src/main/AndroidManifest.xml b/automation/src/main/AndroidManifest.xml new file mode 100644 index 0000000000..c7b7ca4618 --- /dev/null +++ b/automation/src/main/AndroidManifest.xml @@ -0,0 +1,13 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AutomationModule.kt b/automation/src/main/java/info/nightscout/androidaps/automation/di/AutomationModule.kt similarity index 96% rename from app/src/main/java/info/nightscout/androidaps/dependencyInjection/AutomationModule.kt rename to automation/src/main/java/info/nightscout/androidaps/automation/di/AutomationModule.kt index 04aacf5a84..723338631a 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AutomationModule.kt +++ b/automation/src/main/java/info/nightscout/androidaps/automation/di/AutomationModule.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.dependencyInjection +package info.nightscout.androidaps.automation.di import dagger.Module import dagger.android.ContributesAndroidInjector @@ -6,8 +6,6 @@ import info.nightscout.androidaps.plugins.general.automation.AutomationEvent import info.nightscout.androidaps.plugins.general.automation.actions.* import info.nightscout.androidaps.plugins.general.automation.elements.* import info.nightscout.androidaps.plugins.general.automation.triggers.* -import info.nightscout.androidaps.queue.CommandQueue -import info.nightscout.androidaps.queue.commands.* @Module @Suppress("unused") diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventLocationChange.kt b/automation/src/main/java/info/nightscout/androidaps/events/EventLocationChange.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/events/EventLocationChange.kt rename to automation/src/main/java/info/nightscout/androidaps/events/EventLocationChange.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationEvent.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationEvent.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationEvent.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationEvent.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationFragment.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationFragment.kt similarity index 98% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationFragment.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationFragment.kt index 31819ac0bb..54583576cc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationFragment.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationFragment.kt @@ -17,9 +17,9 @@ import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import dagger.android.HasAndroidInjector import dagger.android.support.DaggerFragment -import info.nightscout.androidaps.R -import info.nightscout.androidaps.databinding.AutomationEventItemBinding -import info.nightscout.androidaps.databinding.AutomationFragmentBinding +import info.nightscout.androidaps.automation.R +import info.nightscout.androidaps.automation.databinding.AutomationEventItemBinding +import info.nightscout.androidaps.automation.databinding.AutomationFragmentBinding import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.automation.dialogs.EditEventDialog diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationPlugin.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationPlugin.kt similarity index 95% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationPlugin.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationPlugin.kt index 480ef913cf..d43e0b6389 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationPlugin.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationPlugin.kt @@ -5,36 +5,31 @@ import android.os.Handler import android.os.HandlerThread import android.os.SystemClock import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.Config -import info.nightscout.androidaps.R -import info.nightscout.androidaps.events.EventBTChange -import info.nightscout.androidaps.events.EventChargingState -import info.nightscout.androidaps.events.EventLocationChange -import info.nightscout.androidaps.events.EventNetworkChange -import info.nightscout.androidaps.events.EventPreferenceChange +import info.nightscout.androidaps.automation.R +import info.nightscout.androidaps.events.* +import info.nightscout.androidaps.interfaces.ConfigInterface +import info.nightscout.androidaps.interfaces.LoopInterface import info.nightscout.androidaps.interfaces.PluginBase 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.plugins.aps.loop.LoopPlugin import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker import info.nightscout.androidaps.plugins.general.automation.actions.* import info.nightscout.androidaps.plugins.general.automation.events.EventAutomationDataChanged import info.nightscout.androidaps.plugins.general.automation.events.EventAutomationUpdateGui import info.nightscout.androidaps.plugins.general.automation.triggers.* -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished import info.nightscout.androidaps.queue.Callback import info.nightscout.androidaps.services.LocationServiceHelper import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.T -import io.reactivex.rxkotlin.plusAssign import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.rx.AapsSchedulers import info.nightscout.androidaps.utils.sharedPreferences.SP import io.reactivex.disposables.CompositeDisposable +import io.reactivex.rxkotlin.plusAssign import org.json.JSONArray import org.json.JSONException import org.json.JSONObject @@ -50,12 +45,12 @@ class AutomationPlugin @Inject constructor( private val context: Context, private val sp: SP, private val fabricPrivacy: FabricPrivacy, - private val loopPlugin: LoopPlugin, + private val loopPlugin: LoopInterface, private val rxBus: RxBusWrapper, private val constraintChecker: ConstraintChecker, aapsLogger: AAPSLogger, private val aapsSchedulers: AapsSchedulers, - private val config: Config, + private val config: ConfigInterface, private val locationServiceHelper: LocationServiceHelper, private val dateUtil: DateUtil ) : PluginBase(PluginDescription() @@ -188,7 +183,7 @@ class AutomationPlugin @Inject constructor( private fun processActions() { var userEventsEnabled = config.APS if (config.APS) { - if (loopPlugin.isSuspended || !loopPlugin.isEnabled()) { + if (loopPlugin.isSuspended || !(loopPlugin as PluginBase).isEnabled()) { aapsLogger.debug(LTag.AUTOMATION, "Loop deactivated") executionLog.add(resourceHelper.gs(R.string.smscommunicator_loopisdisabled)) userEventsEnabled = false diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/Action.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/Action.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/Action.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/Action.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionAlarm.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionAlarm.kt similarity index 98% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionAlarm.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionAlarm.kt index 93411a1275..e483912af6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionAlarm.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionAlarm.kt @@ -4,7 +4,7 @@ import android.content.Context import android.widget.LinearLayout import androidx.annotation.DrawableRes import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.automation.elements.InputString diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionDummy.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionDummy.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionDummy.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionDummy.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopDisable.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopDisable.kt similarity index 76% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopDisable.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopDisable.kt index f0b0674625..a629243628 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopDisable.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopDisable.kt @@ -2,22 +2,23 @@ package info.nightscout.androidaps.plugins.general.automation.actions import androidx.annotation.DrawableRes import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.events.EventRefreshOverview import info.nightscout.androidaps.interfaces.CommandQueueProvider +import info.nightscout.androidaps.interfaces.ConfigBuilderInterface +import info.nightscout.androidaps.interfaces.LoopInterface +import info.nightscout.androidaps.interfaces.PluginBase import info.nightscout.androidaps.interfaces.PluginType -import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin import info.nightscout.androidaps.queue.Callback import info.nightscout.androidaps.utils.resources.ResourceHelper import javax.inject.Inject class ActionLoopDisable(injector: HasAndroidInjector) : Action(injector) { - @Inject lateinit var loopPlugin: LoopPlugin + @Inject lateinit var loopPlugin: LoopInterface @Inject lateinit var resourceHelper: ResourceHelper - @Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin + @Inject lateinit var configBuilderPlugin: ConfigBuilderInterface @Inject lateinit var commandQueue: CommandQueueProvider @Inject lateinit var rxBus: RxBusWrapper @@ -26,8 +27,8 @@ class ActionLoopDisable(injector: HasAndroidInjector) : Action(injector) { @DrawableRes override fun icon(): Int = R.drawable.ic_stop_24dp override fun doAction(callback: Callback) { - if (loopPlugin.isEnabled(PluginType.LOOP)) { - loopPlugin.setPluginEnabled(PluginType.LOOP, false) + if ((loopPlugin as PluginBase).isEnabled()) { + (loopPlugin as PluginBase).setPluginEnabled(PluginType.LOOP, false) configBuilderPlugin.storeSettings("ActionLoopDisable") commandQueue.cancelTempBasal(true, object : Callback() { override fun run() { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopEnable.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopEnable.kt similarity index 74% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopEnable.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopEnable.kt index 126ee62ce5..43c7e897f7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopEnable.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopEnable.kt @@ -2,13 +2,14 @@ package info.nightscout.androidaps.plugins.general.automation.actions import androidx.annotation.DrawableRes import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.events.EventRefreshOverview +import info.nightscout.androidaps.interfaces.ConfigBuilderInterface +import info.nightscout.androidaps.interfaces.LoopInterface +import info.nightscout.androidaps.interfaces.PluginBase import info.nightscout.androidaps.interfaces.PluginType -import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin import info.nightscout.androidaps.queue.Callback import info.nightscout.androidaps.utils.resources.ResourceHelper import javax.inject.Inject @@ -16,8 +17,8 @@ import javax.inject.Inject class ActionLoopEnable(injector: HasAndroidInjector) : Action(injector) { @Inject lateinit var resourceHelper: ResourceHelper - @Inject lateinit var loopPlugin: LoopPlugin - @Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin + @Inject lateinit var loopPlugin: LoopInterface + @Inject lateinit var configBuilderPlugin: ConfigBuilderInterface @Inject lateinit var rxBus: RxBusWrapper override fun friendlyName(): Int = R.string.enableloop @@ -25,8 +26,8 @@ class ActionLoopEnable(injector: HasAndroidInjector) : Action(injector) { @DrawableRes override fun icon(): Int = R.drawable.ic_play_circle_outline_24dp override fun doAction(callback: Callback) { - if (!loopPlugin.isEnabled(PluginType.LOOP)) { - loopPlugin.setPluginEnabled(PluginType.LOOP, true) + if (!(loopPlugin as PluginBase).isEnabled()) { + (loopPlugin as PluginBase).setPluginEnabled(PluginType.LOOP, true) configBuilderPlugin.storeSettings("ActionLoopEnable") rxBus.send(EventRefreshOverview("ActionLoopEnable")) callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run() diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopResume.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopResume.kt similarity index 83% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopResume.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopResume.kt index 461de03ccf..4e910c594c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopResume.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopResume.kt @@ -2,20 +2,20 @@ package info.nightscout.androidaps.plugins.general.automation.actions import androidx.annotation.DrawableRes import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.events.EventRefreshOverview -import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin +import info.nightscout.androidaps.interfaces.ConfigBuilderInterface +import info.nightscout.androidaps.interfaces.LoopInterface import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin import info.nightscout.androidaps.queue.Callback import info.nightscout.androidaps.utils.resources.ResourceHelper import javax.inject.Inject class ActionLoopResume(injector: HasAndroidInjector) : Action(injector) { @Inject lateinit var resourceHelper: ResourceHelper - @Inject lateinit var loopPlugin: LoopPlugin - @Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin + @Inject lateinit var loopPlugin: LoopInterface + @Inject lateinit var configBuilderPlugin: ConfigBuilderInterface @Inject lateinit var rxBus: RxBusWrapper override fun friendlyName(): Int = R.string.resumeloop diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopSuspend.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopSuspend.kt similarity index 94% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopSuspend.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopSuspend.kt index 576209a255..033a46d628 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopSuspend.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopSuspend.kt @@ -3,10 +3,10 @@ package info.nightscout.androidaps.plugins.general.automation.actions import android.widget.LinearLayout import androidx.annotation.DrawableRes import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.events.EventRefreshOverview -import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin +import info.nightscout.androidaps.interfaces.LoopInterface import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.automation.elements.InputDuration import info.nightscout.androidaps.plugins.general.automation.elements.LabelWithElement @@ -19,7 +19,7 @@ import javax.inject.Inject class ActionLoopSuspend(injector: HasAndroidInjector) : Action(injector) { @Inject lateinit var resourceHelper: ResourceHelper - @Inject lateinit var loopPlugin: LoopPlugin + @Inject lateinit var loopPlugin: LoopInterface @Inject lateinit var rxBus: RxBusWrapper var minutes = InputDuration(injector, 30, InputDuration.TimeUnit.MINUTES) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionNotification.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionNotification.kt similarity index 98% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionNotification.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionNotification.kt index 6edc1e146c..fdf6d7177f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionNotification.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionNotification.kt @@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.actions import android.widget.LinearLayout import androidx.annotation.DrawableRes import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.events.EventRefreshOverview import info.nightscout.androidaps.plugins.bus.RxBusWrapper @@ -20,6 +20,7 @@ import org.json.JSONObject import javax.inject.Inject class ActionNotification(injector: HasAndroidInjector) : Action(injector) { + @Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var rxBus: RxBusWrapper @Inject lateinit var nsUpload: NSUpload diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitch.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitch.kt similarity index 98% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitch.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitch.kt index 693e7f5069..eb36b44bb5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitch.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitch.kt @@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.actions import android.widget.LinearLayout import androidx.annotation.DrawableRes import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.logging.LTag diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchPercent.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchPercent.kt similarity index 98% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchPercent.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchPercent.kt index 229c7e7942..e8b7dc74bb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchPercent.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchPercent.kt @@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.actions import android.widget.LinearLayout import androidx.annotation.DrawableRes import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.plugins.general.automation.elements.Comparator diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionSendSMS.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionSendSMS.kt similarity index 91% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionSendSMS.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionSendSMS.kt index 5a086cf64c..22c3b134d7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionSendSMS.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionSendSMS.kt @@ -2,12 +2,12 @@ package info.nightscout.androidaps.plugins.general.automation.actions import android.widget.LinearLayout import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.data.PumpEnactResult +import info.nightscout.androidaps.interfaces.SmsCommunicatorInterface import info.nightscout.androidaps.plugins.general.automation.elements.InputString import info.nightscout.androidaps.plugins.general.automation.elements.LabelWithElement import info.nightscout.androidaps.plugins.general.automation.elements.LayoutBuilder -import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin import info.nightscout.androidaps.queue.Callback import info.nightscout.androidaps.utils.JsonHelper import info.nightscout.androidaps.utils.resources.ResourceHelper @@ -17,7 +17,7 @@ import javax.inject.Inject class ActionSendSMS(injector: HasAndroidInjector) : Action(injector) { @Inject lateinit var resourceHelper: ResourceHelper - @Inject lateinit var smsCommunicatorPlugin: SmsCommunicatorPlugin + @Inject lateinit var smsCommunicatorPlugin: SmsCommunicatorInterface var text = InputString(injector) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStartTempTarget.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStartTempTarget.kt similarity index 98% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStartTempTarget.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStartTempTarget.kt index f6deb7d12f..6b0af578dc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStartTempTarget.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStartTempTarget.kt @@ -4,7 +4,7 @@ import android.widget.LinearLayout import androidx.annotation.DrawableRes import dagger.android.HasAndroidInjector import info.nightscout.androidaps.Constants -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.db.Source diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStopTempTarget.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStopTempTarget.kt similarity index 96% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStopTempTarget.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStopTempTarget.kt index 4a8b5eb68d..f99d3465ff 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStopTempTarget.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStopTempTarget.kt @@ -1,7 +1,7 @@ package info.nightscout.androidaps.plugins.general.automation.actions import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.db.Source import info.nightscout.androidaps.db.TempTarget diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/ChooseActionDialog.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/ChooseActionDialog.kt similarity index 92% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/ChooseActionDialog.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/ChooseActionDialog.kt index 3219b0d922..cf831c4481 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/ChooseActionDialog.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/ChooseActionDialog.kt @@ -5,8 +5,8 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.RadioButton -import info.nightscout.androidaps.MainApp -import info.nightscout.androidaps.databinding.AutomationDialogChooseActionBinding +import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.automation.databinding.AutomationDialogChooseActionBinding import info.nightscout.androidaps.dialogs.DialogFragmentWithDate import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.automation.AutomationPlugin @@ -20,7 +20,7 @@ class ChooseActionDialog : DialogFragmentWithDate() { @Inject lateinit var automationPlugin: AutomationPlugin @Inject lateinit var rxBus: RxBusWrapper - @Inject lateinit var mainApp: MainApp + @Inject lateinit var injector: HasAndroidInjector private var checkedIndex = -1 @@ -31,7 +31,7 @@ class ChooseActionDialog : DialogFragmentWithDate() { private val binding get() = _binding!! override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle?): View? { + savedInstanceState: Bundle?): View { // restore checked radio button savedInstanceState?.let { bundle -> checkedIndex = bundle.getInt("checkedIndex") @@ -77,7 +77,7 @@ class ChooseActionDialog : DialogFragmentWithDate() { private fun instantiateAction(): Action? { return getActionClass()?.let { val clazz = Class.forName(it).kotlin - clazz.primaryConstructor?.call(mainApp) as Action + clazz.primaryConstructor?.call(injector) as Action } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/ChooseTriggerDialog.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/ChooseTriggerDialog.kt similarity index 92% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/ChooseTriggerDialog.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/ChooseTriggerDialog.kt index ff03075b0a..df8d9979a9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/ChooseTriggerDialog.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/ChooseTriggerDialog.kt @@ -5,8 +5,8 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.RadioButton -import info.nightscout.androidaps.MainApp -import info.nightscout.androidaps.databinding.AutomationDialogChooseTriggerBinding +import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.automation.databinding.AutomationDialogChooseTriggerBinding import info.nightscout.androidaps.dialogs.DialogFragmentWithDate import info.nightscout.androidaps.plugins.general.automation.AutomationPlugin import info.nightscout.androidaps.plugins.general.automation.triggers.Trigger @@ -16,7 +16,7 @@ import kotlin.reflect.full.primaryConstructor class ChooseTriggerDialog : DialogFragmentWithDate() { @Inject lateinit var automationPlugin: AutomationPlugin - @Inject lateinit var mainApp: MainApp + @Inject lateinit var injector: HasAndroidInjector private var checkedIndex = -1 private var clickListener: OnClickListener? = null @@ -82,7 +82,7 @@ class ChooseTriggerDialog : DialogFragmentWithDate() { private fun instantiateTrigger(): Trigger? { return getTriggerClass()?.let { val clazz = Class.forName(it).kotlin - clazz.primaryConstructor?.call(mainApp) as Trigger + clazz.primaryConstructor?.call(injector) as Trigger } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/EditActionDialog.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/EditActionDialog.kt similarity index 91% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/EditActionDialog.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/EditActionDialog.kt index 0b4c440a3b..269080b948 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/EditActionDialog.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/EditActionDialog.kt @@ -4,8 +4,8 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import info.nightscout.androidaps.MainApp -import info.nightscout.androidaps.databinding.AutomationDialogActionBinding +import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.automation.databinding.AutomationDialogActionBinding import info.nightscout.androidaps.dialogs.DialogFragmentWithDate import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.automation.actions.Action @@ -17,7 +17,7 @@ import javax.inject.Inject class EditActionDialog : DialogFragmentWithDate() { @Inject lateinit var rxBus: RxBusWrapper - @Inject lateinit var mainApp: MainApp + @Inject lateinit var injector: HasAndroidInjector private var action: Action? = null private var actionPosition: Int = -1 @@ -33,7 +33,7 @@ class EditActionDialog : DialogFragmentWithDate() { // load data from bundle (savedInstanceState ?: arguments)?.let { bundle -> actionPosition = bundle.getInt("actionPosition", -1) - bundle.getString("action")?.let { action = ActionDummy(mainApp).instantiate(JSONObject(it)) } + bundle.getString("action")?.let { action = ActionDummy(injector).instantiate(JSONObject(it)) } } onCreateViewGeneral() _binding = AutomationDialogActionBinding.inflate(inflater, container, false) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/EditEventDialog.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/EditEventDialog.kt similarity index 98% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/EditEventDialog.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/EditEventDialog.kt index 68f56a8f98..b408ff76fa 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/EditEventDialog.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/EditEventDialog.kt @@ -10,8 +10,8 @@ import android.widget.TextView import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R -import info.nightscout.androidaps.databinding.AutomationDialogEventBinding +import info.nightscout.androidaps.automation.R +import info.nightscout.androidaps.automation.databinding.AutomationDialogEventBinding import info.nightscout.androidaps.dialogs.DialogFragmentWithDate import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.automation.AutomationEvent diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/EditTriggerDialog.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/EditTriggerDialog.kt similarity index 97% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/EditTriggerDialog.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/EditTriggerDialog.kt index bb2dc1e2e0..7a0225a686 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/EditTriggerDialog.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/EditTriggerDialog.kt @@ -5,7 +5,7 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.databinding.AutomationDialogEditTriggerBinding +import info.nightscout.androidaps.automation.databinding.AutomationDialogEditTriggerBinding import info.nightscout.androidaps.dialogs.DialogFragmentWithDate import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.automation.events.EventAutomationUpdateTrigger diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dragHelpers/ItemTouchHelperAdapter.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/dragHelpers/ItemTouchHelperAdapter.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dragHelpers/ItemTouchHelperAdapter.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/dragHelpers/ItemTouchHelperAdapter.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dragHelpers/ItemTouchHelperViewHolder.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/dragHelpers/ItemTouchHelperViewHolder.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dragHelpers/ItemTouchHelperViewHolder.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/dragHelpers/ItemTouchHelperViewHolder.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dragHelpers/OnStartDragListener.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/dragHelpers/OnStartDragListener.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dragHelpers/OnStartDragListener.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/dragHelpers/OnStartDragListener.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dragHelpers/SimpleItemTouchHelperCallback.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/dragHelpers/SimpleItemTouchHelperCallback.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dragHelpers/SimpleItemTouchHelperCallback.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/dragHelpers/SimpleItemTouchHelperCallback.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/Comparator.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/Comparator.kt similarity index 98% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/Comparator.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/Comparator.kt index 11b8d1b952..7baedc1fd9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/Comparator.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/Comparator.kt @@ -7,7 +7,7 @@ import android.widget.LinearLayout import android.widget.Spinner import androidx.annotation.StringRes import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.utils.resources.ResourceHelper import java.util.* import javax.inject.Inject diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/ComparatorConnect.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/ComparatorConnect.kt similarity index 98% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/ComparatorConnect.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/ComparatorConnect.kt index 5d2d47edf9..4ca9f48afb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/ComparatorConnect.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/ComparatorConnect.kt @@ -7,7 +7,7 @@ import android.widget.LinearLayout import android.widget.Spinner import androidx.annotation.StringRes import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.utils.resources.ResourceHelper import java.util.* import javax.inject.Inject diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/ComparatorExists.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/ComparatorExists.kt similarity index 97% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/ComparatorExists.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/ComparatorExists.kt index cb7eb8a32e..2d7f6adf1a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/ComparatorExists.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/ComparatorExists.kt @@ -7,7 +7,7 @@ import android.widget.LinearLayout import android.widget.Spinner import androidx.annotation.StringRes import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.utils.resources.ResourceHelper import java.util.* import javax.inject.Inject diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/Element.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/Element.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/Element.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/Element.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputBg.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputBg.kt similarity index 97% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputBg.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputBg.kt index 24b48e0fb7..045211f92e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputBg.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputBg.kt @@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.elements import android.widget.LinearLayout import dagger.android.HasAndroidInjector import info.nightscout.androidaps.Constants -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.utils.ui.NumberPicker import java.text.DecimalFormat diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputButton.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputButton.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputButton.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputButton.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDateTime.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDateTime.kt similarity index 96% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDateTime.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDateTime.kt index 2c92fcb75f..95bd31e8fa 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDateTime.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDateTime.kt @@ -9,7 +9,7 @@ import android.view.ViewGroup import android.widget.LinearLayout import android.widget.TextView import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.resources.ResourceHelper import java.util.* @@ -22,7 +22,7 @@ class InputDateTime(injector: HasAndroidInjector) : Element(injector) { var value: Long = DateUtil.now() - constructor(injector: HasAndroidInjector, value: Long) : this(injector) { + @Suppress("unused") constructor(injector: HasAndroidInjector, value: Long) : this(injector) { this.value = value } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDelta.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDelta.kt similarity index 98% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDelta.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDelta.kt index 46b696eaec..ee6886bf58 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDelta.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDelta.kt @@ -8,7 +8,7 @@ import android.widget.LinearLayout import android.widget.Spinner import androidx.annotation.StringRes import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.utils.ui.NumberPicker import info.nightscout.androidaps.utils.resources.ResourceHelper import java.text.DecimalFormat diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDouble.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDouble.kt similarity index 97% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDouble.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDouble.kt index 566315b9eb..c788f31c43 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDouble.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDouble.kt @@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.general.automation.elements import android.widget.LinearLayout import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.utils.ui.NumberPicker import java.text.DecimalFormat diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDropdownMenu.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDropdownMenu.kt similarity index 93% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDropdownMenu.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDropdownMenu.kt index 473d26bb4b..47c967d1a4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDropdownMenu.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDropdownMenu.kt @@ -7,7 +7,7 @@ import android.widget.ArrayAdapter import android.widget.LinearLayout import android.widget.Spinner import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.utils.resources.ResourceHelper import java.util.* import javax.inject.Inject @@ -22,7 +22,7 @@ class InputDropdownMenu(injector: HasAndroidInjector) : Element(injector) { value = name } - constructor(injector: HasAndroidInjector, another: InputDropdownMenu) : this(injector) { + @Suppress("unused") constructor(injector: HasAndroidInjector, another: InputDropdownMenu) : this(injector) { value = another.value } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDuration.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDuration.kt similarity index 97% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDuration.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDuration.kt index c25928d642..8c77d9e0ca 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDuration.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDuration.kt @@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.general.automation.elements import android.widget.LinearLayout import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.utils.ui.MinutesNumberPicker import info.nightscout.androidaps.utils.ui.NumberPicker import java.text.DecimalFormat diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputInsulin.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputInsulin.kt similarity index 94% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputInsulin.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputInsulin.kt index 0903824a94..d27640836e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputInsulin.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputInsulin.kt @@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.general.automation.elements import android.widget.LinearLayout import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.utils.ui.NumberPicker import java.text.DecimalFormat diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputLocationMode.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputLocationMode.kt similarity index 98% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputLocationMode.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputLocationMode.kt index e5e42fa60a..75ec60b68b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputLocationMode.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputLocationMode.kt @@ -7,7 +7,7 @@ import android.widget.LinearLayout import android.widget.Spinner import androidx.annotation.StringRes import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.utils.resources.ResourceHelper import java.util.* import javax.inject.Inject diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputPercent.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputPercent.kt similarity index 95% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputPercent.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputPercent.kt index 05524abc40..5c87028760 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputPercent.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputPercent.kt @@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.general.automation.elements import android.widget.LinearLayout import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.utils.ui.NumberPicker import java.text.DecimalFormat diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputProfileName.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputProfileName.kt similarity index 97% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputProfileName.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputProfileName.kt index 57f2b904b7..a582c268b5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputProfileName.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputProfileName.kt @@ -7,7 +7,7 @@ import android.widget.ArrayAdapter import android.widget.LinearLayout import android.widget.Spinner import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.utils.resources.ResourceHelper import javax.inject.Inject diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputString.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputString.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputString.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputString.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTempTarget.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTempTarget.kt similarity index 97% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTempTarget.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTempTarget.kt index 4f58be8167..1fd1abbc3c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTempTarget.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTempTarget.kt @@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.elements import android.widget.LinearLayout import dagger.android.HasAndroidInjector import info.nightscout.androidaps.Constants -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.utils.ui.NumberPicker import java.text.DecimalFormat diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTime.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTime.kt similarity index 98% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTime.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTime.kt index bd0622b29b..ec0f8af85c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTime.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTime.kt @@ -8,7 +8,7 @@ import android.view.ViewGroup import android.widget.LinearLayout import android.widget.TextView import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.MidnightTime diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTimeRange.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTimeRange.kt similarity index 98% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTimeRange.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTimeRange.kt index f8d0a369dc..9a1a6f4ecd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTimeRange.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTimeRange.kt @@ -8,7 +8,7 @@ import android.view.ViewGroup import android.widget.LinearLayout import android.widget.TextView import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.MidnightTime diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputWeekDay.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputWeekDay.kt similarity index 98% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputWeekDay.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputWeekDay.kt index 53733acfc8..57dd962b9e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputWeekDay.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputWeekDay.kt @@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.elements import android.widget.LinearLayout import androidx.annotation.StringRes import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.utils.ui.WeekdayPicker import java.util.* diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/LabelWithElement.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/LabelWithElement.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/LabelWithElement.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/LabelWithElement.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/LayoutBuilder.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/LayoutBuilder.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/LayoutBuilder.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/LayoutBuilder.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/StaticLabel.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/StaticLabel.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/StaticLabel.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/StaticLabel.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/events/EventAutomationAddAction.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/events/EventAutomationAddAction.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/events/EventAutomationAddAction.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/events/EventAutomationAddAction.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/events/EventAutomationDataChanged.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/events/EventAutomationDataChanged.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/events/EventAutomationDataChanged.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/events/EventAutomationDataChanged.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/events/EventAutomationUpdateAction.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/events/EventAutomationUpdateAction.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/events/EventAutomationUpdateAction.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/events/EventAutomationUpdateAction.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/events/EventAutomationUpdateGui.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/events/EventAutomationUpdateGui.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/events/EventAutomationUpdateGui.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/events/EventAutomationUpdateGui.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/events/EventAutomationUpdateTrigger.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/events/EventAutomationUpdateTrigger.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/events/EventAutomationUpdateTrigger.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/events/EventAutomationUpdateTrigger.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/events/EventTriggerChanged.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/events/EventTriggerChanged.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/events/EventTriggerChanged.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/events/EventTriggerChanged.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/events/EventTriggerClone.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/events/EventTriggerClone.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/events/EventTriggerClone.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/events/EventTriggerClone.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/events/EventTriggerRemove.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/events/EventTriggerRemove.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/events/EventTriggerRemove.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/events/EventTriggerRemove.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/Trigger.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/Trigger.kt similarity index 93% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/Trigger.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/Trigger.kt index def0d59a6c..a19f2bb5a3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/Trigger.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/Trigger.kt @@ -9,8 +9,9 @@ import android.widget.TextView import androidx.appcompat.app.AppCompatActivity import com.google.common.base.Optional import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.interfaces.ActivePluginProvider +import info.nightscout.androidaps.interfaces.IobCobCalculatorInterface import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.interfaces.TreatmentsInterface import info.nightscout.androidaps.logging.AAPSLogger @@ -19,7 +20,6 @@ import info.nightscout.androidaps.plugins.general.automation.dialogs.ChooseTrigg import info.nightscout.androidaps.plugins.general.automation.events.EventTriggerChanged import info.nightscout.androidaps.plugins.general.automation.events.EventTriggerClone import info.nightscout.androidaps.plugins.general.automation.events.EventTriggerRemove -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.androidaps.services.LastLocationDataContainer import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP @@ -38,7 +38,7 @@ abstract class Trigger(val injector: HasAndroidInjector) { @Inject lateinit var locationDataContainer: LastLocationDataContainer @Inject lateinit var treatmentsInterface: TreatmentsInterface @Inject lateinit var activePlugin: ActivePluginProvider - @Inject lateinit var iobCobCalculatorPlugin: IobCobCalculatorPlugin + @Inject lateinit var iobCobCalculatorPlugin: IobCobCalculatorInterface init { injector.androidInjector().inject(this) @@ -57,11 +57,11 @@ abstract class Trigger(val injector: HasAndroidInjector) { @JvmStatic fun scanForActivity(cont: Context?): AppCompatActivity? { - when (cont) { - null -> return null - is AppCompatActivity -> return cont - is ContextWrapper -> return scanForActivity(cont.baseContext) - else -> return null + return when (cont) { + null -> null + is AppCompatActivity -> cont + is ContextWrapper -> scanForActivity(cont.baseContext) + else -> null } } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerAutosensValue.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerAutosensValue.kt similarity index 98% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerAutosensValue.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerAutosensValue.kt index 3b3dbe1f68..d45f2220d6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerAutosensValue.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerAutosensValue.kt @@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.triggers import android.widget.LinearLayout import com.google.common.base.Optional import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.general.automation.elements.Comparator import info.nightscout.androidaps.plugins.general.automation.elements.InputDouble @@ -68,7 +68,7 @@ class TriggerAutosensValue(injector: HasAndroidInjector) : Trigger(injector) { override fun friendlyDescription(): String = resourceHelper.gs(R.string.autosenscompared, resourceHelper.gs(comparator.value.stringRes), autosens.value) - override fun icon(): Optional = Optional.of(R.drawable.`ic_as`) + override fun icon(): Optional = Optional.of(R.drawable.ic_as) override fun duplicate(): Trigger = TriggerAutosensValue(injector, this) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBTDevice.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBTDevice.kt similarity index 98% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBTDevice.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBTDevice.kt index 6dfb45be67..35299bbbcd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBTDevice.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBTDevice.kt @@ -5,7 +5,7 @@ import android.content.Context import android.widget.LinearLayout import com.google.common.base.Optional import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.events.EventBTChange import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.general.automation.AutomationPlugin diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBg.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBg.kt similarity index 98% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBg.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBg.kt index bb5988033d..e9bdee88de 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBg.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBg.kt @@ -4,7 +4,7 @@ import android.widget.LinearLayout import com.google.common.base.Optional import dagger.android.HasAndroidInjector import info.nightscout.androidaps.Constants -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.general.automation.elements.Comparator diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBolusAgo.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBolusAgo.kt similarity index 98% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBolusAgo.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBolusAgo.kt index 5ff50b561c..24297f98ab 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBolusAgo.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBolusAgo.kt @@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.triggers import android.widget.LinearLayout import com.google.common.base.Optional import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.general.automation.elements.Comparator import info.nightscout.androidaps.plugins.general.automation.elements.InputDuration diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerCOB.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerCOB.kt similarity index 96% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerCOB.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerCOB.kt index 6d07ef1188..90305a6178 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerCOB.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerCOB.kt @@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.triggers import android.widget.LinearLayout import com.google.common.base.Optional import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.general.automation.elements.Comparator import info.nightscout.androidaps.plugins.general.automation.elements.InputDouble @@ -47,7 +47,7 @@ class TriggerCOB(injector: HasAndroidInjector) : Trigger(injector) { false } } - if (comparator.value.check(cobInfo.displayCob, cob.value)) { + if (cobInfo.displayCob != null && comparator.value.check(cobInfo.displayCob!!, cob.value)) { aapsLogger.debug(LTag.AUTOMATION, "Ready for execution: " + friendlyDescription()) return true } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerConnector.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerConnector.kt similarity index 99% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerConnector.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerConnector.kt index 6d19c24441..fa1487aabd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerConnector.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerConnector.kt @@ -10,7 +10,7 @@ import android.widget.Spinner import androidx.annotation.StringRes import com.google.common.base.Optional import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.utils.JsonHelper.safeGetString import info.nightscout.androidaps.utils.resources.ResourceHelper diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerDelta.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerDelta.kt similarity index 99% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerDelta.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerDelta.kt index ce553cb1a3..4e0e543a6d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerDelta.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerDelta.kt @@ -4,7 +4,7 @@ import android.widget.LinearLayout import com.google.common.base.Optional import dagger.android.HasAndroidInjector import info.nightscout.androidaps.Constants -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.general.automation.elements.Comparator diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerDummy.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerDummy.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerDummy.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerDummy.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerIob.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerIob.kt similarity index 98% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerIob.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerIob.kt index 0db45fcf9c..e6d42c94bb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerIob.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerIob.kt @@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.triggers import android.widget.LinearLayout import com.google.common.base.Optional import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.general.automation.elements.Comparator import info.nightscout.androidaps.plugins.general.automation.elements.InputInsulin diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerLocation.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerLocation.kt similarity index 99% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerLocation.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerLocation.kt index da1ebd4914..5cb460e523 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerLocation.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerLocation.kt @@ -4,7 +4,7 @@ import android.location.Location import android.widget.LinearLayout import com.google.common.base.Optional import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.general.automation.elements.* import info.nightscout.androidaps.utils.JsonHelper diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerProfilePercent.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerProfilePercent.kt similarity index 98% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerProfilePercent.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerProfilePercent.kt index 9a13ebedeb..792b7c077c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerProfilePercent.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerProfilePercent.kt @@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.triggers import android.widget.LinearLayout import com.google.common.base.Optional import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.general.automation.elements.Comparator import info.nightscout.androidaps.plugins.general.automation.elements.InputPercent diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerPumpLastConnection.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerPumpLastConnection.kt similarity index 98% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerPumpLastConnection.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerPumpLastConnection.kt index 3248269997..6de37135c6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerPumpLastConnection.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerPumpLastConnection.kt @@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.triggers import android.widget.LinearLayout import com.google.common.base.Optional import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.general.automation.elements.Comparator import info.nightscout.androidaps.plugins.general.automation.elements.InputDuration @@ -19,6 +19,7 @@ class TriggerPumpLastConnection(injector: HasAndroidInjector) : Trigger(injector var minutesAgo = InputDuration(injector) var comparator = Comparator(injector) + @Suppress("unused") constructor(injector: HasAndroidInjector, value: Int, unit: InputDuration.TimeUnit, compare: Comparator.Compare) : this(injector) { minutesAgo = InputDuration(injector, value, unit) comparator = Comparator(injector, compare) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTime.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTime.kt similarity index 98% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTime.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTime.kt index ffc79e39e1..eae526554c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTime.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTime.kt @@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.triggers import android.widget.LinearLayout import com.google.common.base.Optional import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.general.automation.elements.InputTime diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTempTarget.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTempTarget.kt similarity index 98% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTempTarget.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTempTarget.kt index 25ef553816..78ad54382e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTempTarget.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTempTarget.kt @@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.triggers import android.widget.LinearLayout import com.google.common.base.Optional import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.general.automation.elements.ComparatorExists import info.nightscout.androidaps.plugins.general.automation.elements.LayoutBuilder diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTime.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTime.kt similarity index 93% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTime.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTime.kt index 6641286484..f0f310df03 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTime.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTime.kt @@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.triggers import android.widget.LinearLayout import com.google.common.base.Optional import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.general.automation.elements.InputDateTime import info.nightscout.androidaps.plugins.general.automation.elements.LayoutBuilder @@ -23,7 +23,7 @@ class TriggerTime(injector: HasAndroidInjector) : Trigger(injector) { this.time.value = runAt } - constructor(injector: HasAndroidInjector, triggerTime: TriggerTime) : this(injector) { + @Suppress("unused") constructor(injector: HasAndroidInjector, triggerTime: TriggerTime) : this(injector) { this.time.value = triggerTime.time.value } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeRange.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeRange.kt similarity index 95% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeRange.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeRange.kt index 08f54025bb..24a3268552 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeRange.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeRange.kt @@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.triggers import android.widget.LinearLayout import com.google.common.base.Optional import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.general.automation.elements.InputTimeRange @@ -28,7 +28,7 @@ class TriggerTimeRange(injector: HasAndroidInjector) : Trigger(injector) { range.end = end } - constructor(injector: HasAndroidInjector, triggerTimeRange: TriggerTimeRange) : this(injector) { + @Suppress("unused") constructor(injector: HasAndroidInjector, triggerTimeRange: TriggerTimeRange) : this(injector) { range.start = triggerTimeRange.range.start range.end = triggerTimeRange.range.end } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerWifiSsid.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerWifiSsid.kt similarity index 95% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerWifiSsid.kt rename to automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerWifiSsid.kt index 71839a8fae..df44fc2853 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerWifiSsid.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerWifiSsid.kt @@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.triggers import android.widget.LinearLayout import com.google.common.base.Optional import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.general.automation.elements.Comparator import info.nightscout.androidaps.plugins.general.automation.elements.InputString @@ -21,7 +21,7 @@ class TriggerWifiSsid(injector: HasAndroidInjector) : Trigger(injector) { var ssid = InputString(injector) var comparator = Comparator(injector) - constructor(injector: HasAndroidInjector, ssid: String, compare: Comparator.Compare) : this(injector) { + @Suppress("unused") constructor(injector: HasAndroidInjector, ssid: String, compare: Comparator.Compare) : this(injector) { this.ssid = InputString(injector, ssid) comparator = Comparator(injector, compare) } diff --git a/app/src/main/java/info/nightscout/androidaps/services/LastLocationDataContainer.kt b/automation/src/main/java/info/nightscout/androidaps/services/LastLocationDataContainer.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/services/LastLocationDataContainer.kt rename to automation/src/main/java/info/nightscout/androidaps/services/LastLocationDataContainer.kt diff --git a/app/src/main/java/info/nightscout/androidaps/services/LocationService.kt b/automation/src/main/java/info/nightscout/androidaps/services/LocationService.kt similarity index 97% rename from app/src/main/java/info/nightscout/androidaps/services/LocationService.kt rename to automation/src/main/java/info/nightscout/androidaps/services/LocationService.kt index ae116f03df..aeb3c9f416 100644 --- a/app/src/main/java/info/nightscout/androidaps/services/LocationService.kt +++ b/automation/src/main/java/info/nightscout/androidaps/services/LocationService.kt @@ -16,15 +16,15 @@ import android.os.IBinder import androidx.core.app.ActivityCompat import com.google.android.gms.location.LocationServices import dagger.android.DaggerService -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.events.EventAppExit import info.nightscout.androidaps.events.EventLocationChange +import info.nightscout.androidaps.interfaces.NotificationHolderInterface import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.T -import info.nightscout.androidaps.utils.androidNotification.NotificationHolder import info.nightscout.androidaps.utils.rx.AapsSchedulers import info.nightscout.androidaps.utils.sharedPreferences.SP import io.reactivex.disposables.CompositeDisposable @@ -37,7 +37,7 @@ class LocationService : DaggerService() { @Inject lateinit var sp: SP @Inject lateinit var aapsSchedulers: AapsSchedulers @Inject lateinit var fabricPrivacy: FabricPrivacy - @Inject lateinit var notificationHolder: NotificationHolder + @Inject lateinit var notificationHolder: NotificationHolderInterface @Inject lateinit var lastLocationDataContainer: LastLocationDataContainer private val disposable = CompositeDisposable() diff --git a/app/src/main/java/info/nightscout/androidaps/services/LocationServiceHelper.kt b/automation/src/main/java/info/nightscout/androidaps/services/LocationServiceHelper.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/services/LocationServiceHelper.kt rename to automation/src/main/java/info/nightscout/androidaps/services/LocationServiceHelper.kt diff --git a/app/src/main/res/drawable/border_automation_unit.xml b/automation/src/main/res/drawable/border_automation_unit.xml similarity index 100% rename from app/src/main/res/drawable/border_automation_unit.xml rename to automation/src/main/res/drawable/border_automation_unit.xml diff --git a/app/src/main/res/drawable/ic_action_orange_48dp.xml b/automation/src/main/res/drawable/ic_action_orange_48dp.xml similarity index 100% rename from app/src/main/res/drawable/ic_action_orange_48dp.xml rename to automation/src/main/res/drawable/ic_action_orange_48dp.xml diff --git a/app/src/main/res/drawable/ic_add_black_24dp.xml b/automation/src/main/res/drawable/ic_add_black_24dp.xml similarity index 100% rename from app/src/main/res/drawable/ic_add_black_24dp.xml rename to automation/src/main/res/drawable/ic_add_black_24dp.xml diff --git a/app/src/main/res/drawable/ic_arrow_forward_white_24dp.xml b/automation/src/main/res/drawable/ic_arrow_forward_white_24dp.xml similarity index 100% rename from app/src/main/res/drawable/ic_arrow_forward_white_24dp.xml rename to automation/src/main/res/drawable/ic_arrow_forward_white_24dp.xml diff --git a/app/src/main/res/drawable/ic_as.xml b/automation/src/main/res/drawable/ic_as.xml similarity index 100% rename from app/src/main/res/drawable/ic_as.xml rename to automation/src/main/res/drawable/ic_as.xml diff --git a/app/src/main/res/drawable/ic_auto_delta.xml b/automation/src/main/res/drawable/ic_auto_delta.xml similarity index 100% rename from app/src/main/res/drawable/ic_auto_delta.xml rename to automation/src/main/res/drawable/ic_auto_delta.xml diff --git a/app/src/main/res/drawable/ic_automation.xml b/automation/src/main/res/drawable/ic_automation.xml similarity index 100% rename from app/src/main/res/drawable/ic_automation.xml rename to automation/src/main/res/drawable/ic_automation.xml diff --git a/app/src/main/res/drawable/ic_keyboard_capslock.xml b/automation/src/main/res/drawable/ic_keyboard_capslock.xml similarity index 100% rename from app/src/main/res/drawable/ic_keyboard_capslock.xml rename to automation/src/main/res/drawable/ic_keyboard_capslock.xml diff --git a/app/src/main/res/drawable/ic_keyboard_tab.xml b/automation/src/main/res/drawable/ic_keyboard_tab.xml similarity index 100% rename from app/src/main/res/drawable/ic_keyboard_tab.xml rename to automation/src/main/res/drawable/ic_keyboard_tab.xml diff --git a/app/src/main/res/drawable/ic_location_on.xml b/automation/src/main/res/drawable/ic_location_on.xml similarity index 100% rename from app/src/main/res/drawable/ic_location_on.xml rename to automation/src/main/res/drawable/ic_location_on.xml diff --git a/app/src/main/res/drawable/ic_network_wifi.xml b/automation/src/main/res/drawable/ic_network_wifi.xml similarity index 100% rename from app/src/main/res/drawable/ic_network_wifi.xml rename to automation/src/main/res/drawable/ic_network_wifi.xml diff --git a/app/src/main/res/drawable/ic_notifications.xml b/automation/src/main/res/drawable/ic_notifications.xml similarity index 100% rename from app/src/main/res/drawable/ic_notifications.xml rename to automation/src/main/res/drawable/ic_notifications.xml diff --git a/app/src/main/res/drawable/ic_pause_circle_outline_24dp.xml b/automation/src/main/res/drawable/ic_pause_circle_outline_24dp.xml similarity index 100% rename from app/src/main/res/drawable/ic_pause_circle_outline_24dp.xml rename to automation/src/main/res/drawable/ic_pause_circle_outline_24dp.xml diff --git a/app/src/main/res/drawable/ic_play_circle_outline_24dp.xml b/automation/src/main/res/drawable/ic_play_circle_outline_24dp.xml similarity index 100% rename from app/src/main/res/drawable/ic_play_circle_outline_24dp.xml rename to automation/src/main/res/drawable/ic_play_circle_outline_24dp.xml diff --git a/app/src/main/res/drawable/ic_reorder_gray_24dp.xml b/automation/src/main/res/drawable/ic_reorder_gray_24dp.xml similarity index 100% rename from app/src/main/res/drawable/ic_reorder_gray_24dp.xml rename to automation/src/main/res/drawable/ic_reorder_gray_24dp.xml diff --git a/app/src/main/res/drawable/ic_replay_24dp.xml b/automation/src/main/res/drawable/ic_replay_24dp.xml similarity index 100% rename from app/src/main/res/drawable/ic_replay_24dp.xml rename to automation/src/main/res/drawable/ic_replay_24dp.xml diff --git a/app/src/main/res/drawable/ic_stop_24dp.xml b/automation/src/main/res/drawable/ic_stop_24dp.xml similarity index 100% rename from app/src/main/res/drawable/ic_stop_24dp.xml rename to automation/src/main/res/drawable/ic_stop_24dp.xml diff --git a/app/src/main/res/drawable/ic_trigger_green_48dp.xml b/automation/src/main/res/drawable/ic_trigger_green_48dp.xml similarity index 100% rename from app/src/main/res/drawable/ic_trigger_green_48dp.xml rename to automation/src/main/res/drawable/ic_trigger_green_48dp.xml diff --git a/app/src/main/res/layout/automation_action_item.xml b/automation/src/main/res/layout/automation_action_item.xml similarity index 100% rename from app/src/main/res/layout/automation_action_item.xml rename to automation/src/main/res/layout/automation_action_item.xml diff --git a/app/src/main/res/layout/automation_dialog_action.xml b/automation/src/main/res/layout/automation_dialog_action.xml similarity index 100% rename from app/src/main/res/layout/automation_dialog_action.xml rename to automation/src/main/res/layout/automation_dialog_action.xml diff --git a/app/src/main/res/layout/automation_dialog_choose_action.xml b/automation/src/main/res/layout/automation_dialog_choose_action.xml similarity index 100% rename from app/src/main/res/layout/automation_dialog_choose_action.xml rename to automation/src/main/res/layout/automation_dialog_choose_action.xml diff --git a/app/src/main/res/layout/automation_dialog_choose_trigger.xml b/automation/src/main/res/layout/automation_dialog_choose_trigger.xml similarity index 100% rename from app/src/main/res/layout/automation_dialog_choose_trigger.xml rename to automation/src/main/res/layout/automation_dialog_choose_trigger.xml diff --git a/app/src/main/res/layout/automation_dialog_edit_trigger.xml b/automation/src/main/res/layout/automation_dialog_edit_trigger.xml similarity index 100% rename from app/src/main/res/layout/automation_dialog_edit_trigger.xml rename to automation/src/main/res/layout/automation_dialog_edit_trigger.xml diff --git a/app/src/main/res/layout/automation_dialog_event.xml b/automation/src/main/res/layout/automation_dialog_event.xml similarity index 100% rename from app/src/main/res/layout/automation_dialog_event.xml rename to automation/src/main/res/layout/automation_dialog_event.xml diff --git a/app/src/main/res/layout/automation_event_item.xml b/automation/src/main/res/layout/automation_event_item.xml similarity index 100% rename from app/src/main/res/layout/automation_event_item.xml rename to automation/src/main/res/layout/automation_event_item.xml diff --git a/app/src/main/res/layout/automation_fragment.xml b/automation/src/main/res/layout/automation_fragment.xml similarity index 100% rename from app/src/main/res/layout/automation_fragment.xml rename to automation/src/main/res/layout/automation_fragment.xml diff --git a/automation/src/main/res/values/arrays.xml b/automation/src/main/res/values/arrays.xml new file mode 100644 index 0000000000..57a20111d8 --- /dev/null +++ b/automation/src/main/res/values/arrays.xml @@ -0,0 +1,15 @@ + + + + @string/use_passive_location + @string/use_network_location + @string/use_gps_location + + + + PASSIVE + NETWORK + GPS + + + \ No newline at end of file diff --git a/automation/src/main/res/values/strings.xml b/automation/src/main/res/values/strings.xml new file mode 100644 index 0000000000..fd6c5de741 --- /dev/null +++ b/automation/src/main/res/values/strings.xml @@ -0,0 +1,114 @@ + + + location + + Auto + Automation + User defined automation tasks + Please enter a task name. + Please specify at least one trigger. + Please specify at least one action. + Alarm: %1$s + Alarm: + Msg: + Already enabled + Already disabled + Already suspended + Not suspended + Suspend loop for %1$d min + Notification: %1$s + Change profile to + Change profile to %1$s + Last connection to pump + Last connection to pump [minutes ago] + Last connection to pump %1$s %2$s min ago + Already set + Profile percentage + Start profile %1$d%% + Start profile %1$d%% for %2$d min + Percent [%]: + Send SMS: %1$s + Send SMS to all numbers + Send SMS with text + Start temp target + Stop temp target + is lesser than + is equal or lesser than + is equal to + is equal or greater than + is greater than + is not available + Glucose is not available + Glucose %1$s %2$.0f %3$s + Glucose %1$s %2$.1f %3$s + Profile pct %1$s %2$d + IOB %1$s %2$.1f + And + Or + Exclusive or + At %1$s + Use network location + Use GPS location + Use passive location + Location service + On connect + On disconnect + Short avg. delta + Long avg. delta + Delta + %1$s %2$s + When + When you are inside the area + When you are outside the area + When you enter the area named + When you leave the area named + Time range + Time is between %1$s and %2$s + Between + Sun + Sat + Fri + Thu + Wed + Tue + Mon + DEL + ADD + COPY + Temp target %1$s + Bluetooth connection to device %1$s %2$s + Connection to Bluetooth device + WiFi SSID %1$s %2$s + Autosens %1$s %2$s %% + Autosens % + %3$s %1$s %2$s + BG difference + BG difference [%1$s] + Current Location + Location + Lat: + Lon: + Glucose [%1$s]: + Last bolus ago + Last bolus time %1$s %2$s min ago + COB + COB %1$s %2$.0f + IOB [U]: + Dist [m]: + Recurring time + Every + Never + Condition: + Action: + Task name + EDIT + Choose an action type + Choose a trigger type + Triggers: + REMOVE + Preconditions: + Automation event + Reorder + + + \ No newline at end of file diff --git a/app/src/main/res/xml/pref_automation.xml b/automation/src/main/res/xml/pref_automation.xml similarity index 100% rename from app/src/main/res/xml/pref_automation.xml rename to automation/src/main/res/xml/pref_automation.xml diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/AutomationEventTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/AutomationEventTest.kt similarity index 89% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/AutomationEventTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/AutomationEventTest.kt index 9ac5cb8d07..cf9522fcb4 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/AutomationEventTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/AutomationEventTest.kt @@ -3,9 +3,9 @@ package info.nightscout.androidaps.plugins.general.automation import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.androidaps.TestBase -import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin +import info.nightscout.androidaps.interfaces.ConfigBuilderInterface +import info.nightscout.androidaps.interfaces.LoopInterface import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin import info.nightscout.androidaps.plugins.general.automation.actions.ActionLoopEnable import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerConnectorTest import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerDummy @@ -15,16 +15,14 @@ import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mock -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest(ConfigBuilderPlugin::class) class AutomationEventTest : TestBase() { - @Mock lateinit var loopPlugin: LoopPlugin + @Mock lateinit var loopPlugin: LoopInterface @Mock lateinit var resourceHelper: ResourceHelper - @Mock lateinit var configBuilderPlugin: ConfigBuilderPlugin + @Mock lateinit var configBuilderPlugin: ConfigBuilderInterface var injector: HasAndroidInjector = HasAndroidInjector { AndroidInjector { diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/ComposeTriggerTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/ComposeTriggerTest.kt similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/ComposeTriggerTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/ComposeTriggerTest.kt diff --git a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/TestBase.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/TestBase.kt new file mode 100644 index 0000000000..573c9dcbcc --- /dev/null +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/TestBase.kt @@ -0,0 +1,40 @@ +package info.nightscout.androidaps + +import info.nightscout.androidaps.logging.AAPSLoggerTest +import info.nightscout.androidaps.utils.rx.AapsSchedulers +import info.nightscout.androidaps.utils.rx.TestAapsSchedulers +import org.junit.Before +import org.junit.Rule +import org.mockito.Mockito +import org.mockito.junit.MockitoJUnit +import org.mockito.junit.MockitoRule +import java.util.* + +@Suppress("SpellCheckingInspection") +open class TestBase { + + val aapsLogger = AAPSLoggerTest() + val aapsSchedulers: AapsSchedulers = TestAapsSchedulers() + + // Add a JUnit rule that will setup the @Mock annotated vars and log. + // Another possibility would be to add `MockitoAnnotations.initMocks(this) to the setup method. + @get:Rule + val mockitoRule: MockitoRule = MockitoJUnit.rule() + + @Before + fun setupLocale() { + Locale.setDefault(Locale.ENGLISH) + System.setProperty("disableFirebase", "true") + } + + // Workaround for Kotlin nullability. + // https://medium.com/@elye.project/befriending-kotlin-and-mockito-1c2e7b0ef791 + // https://stackoverflow.com/questions/30305217/is-it-possible-to-use-mockito-in-kotlin + fun anyObject(): T { + Mockito.any() + return uninitialized() + } + + @Suppress("Unchecked_Cast") + fun uninitialized(): T = null as T +} \ No newline at end of file diff --git a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/TestBaseWithProfile.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/TestBaseWithProfile.kt new file mode 100644 index 0000000000..e3e5c7391b --- /dev/null +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/TestBaseWithProfile.kt @@ -0,0 +1,82 @@ +package info.nightscout.androidaps + +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.data.Profile +import info.nightscout.androidaps.db.ProfileSwitch +import info.nightscout.androidaps.db.Treatment +import info.nightscout.androidaps.interfaces.ActivePluginProvider +import info.nightscout.androidaps.interfaces.ConfigInterface +import info.nightscout.androidaps.interfaces.ProfileFunction +import info.nightscout.androidaps.interfaces.ProfileStore +import info.nightscout.androidaps.interfaces.TreatmentsInterface +import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.utils.DateUtil +import info.nightscout.androidaps.utils.DefaultValueHelper +import info.nightscout.androidaps.utils.FabricPrivacy +import info.nightscout.androidaps.utils.resources.ResourceHelper +import org.json.JSONObject +import org.junit.Before +import org.mockito.Mock +import org.powermock.core.classloader.annotations.PrepareForTest + +@Suppress("SpellCheckingInspection") +@PrepareForTest(FabricPrivacy::class) +open class TestBaseWithProfile : TestBase() { + + @Mock lateinit var activePluginProvider: ActivePluginProvider + @Mock lateinit var resourceHelper: ResourceHelper + @Mock lateinit var treatmentsInterface: TreatmentsInterface + @Mock lateinit var fabricPrivacy: FabricPrivacy + @Mock lateinit var profileFunction: ProfileFunction + @Mock lateinit var defaultValueHelper: DefaultValueHelper + @Mock lateinit var dateUtil: DateUtil + @Mock lateinit var configInterface: ConfigInterface + + val rxBus = RxBusWrapper(aapsSchedulers) + + val profileInjector = HasAndroidInjector { + AndroidInjector { + if (it is Profile) { + it.aapsLogger = aapsLogger + it.activePlugin = activePluginProvider + it.resourceHelper = resourceHelper + it.rxBus = rxBus + it.fabricPrivacy = fabricPrivacy + it.configInterface = configInterface + } + if (it is ProfileSwitch) { + it.treatmentsPlugin = treatmentsInterface + it.aapsLogger = aapsLogger + it.rxBus = rxBus + it.resourceHelper = resourceHelper + it.dateUtil = dateUtil + } + if (it is Treatment) { + it.activePlugin = activePluginProvider + it.profileFunction = profileFunction + it.defaultValueHelper = defaultValueHelper + it.resourceHelper = resourceHelper + } + } + } + + private lateinit var validProfileJSON: String + lateinit var validProfile: Profile + @Suppress("PropertyName") val TESTPROFILENAME = "someProfile" + + @Before + fun prepareMock() { + validProfileJSON = "{\"dia\":\"3\",\"carbratio\":[{\"time\":\"00:00\",\"value\":\"30\"}],\"carbs_hr\":\"20\",\"delay\":\"20\",\"sens\":[{\"time\":\"00:00\",\"value\":\"100\"},{\"time\":\"2:00\",\"value\":\"110\"}],\"timezone\":\"UTC\",\"basal\":[{\"time\":\"00:00\",\"value\":\"1\"}],\"target_low\":[{\"time\":\"00:00\",\"value\":\"4\"}],\"target_high\":[{\"time\":\"00:00\",\"value\":\"5\"}],\"startDate\":\"1970-01-01T00:00:00.000Z\",\"units\":\"mmol\"}" + validProfile = Profile(profileInjector, JSONObject(validProfileJSON), Constants.MGDL) + } + + fun getValidProfileStore(): ProfileStore { + val json = JSONObject() + val store = JSONObject() + store.put(TESTPROFILENAME, JSONObject(validProfileJSON)) + json.put("defaultProfile", TESTPROFILENAME) + json.put("store", store) + return ProfileStore(profileInjector, json) + } +} \ No newline at end of file diff --git a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/TestPumpPlugin.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/TestPumpPlugin.kt new file mode 100644 index 0000000000..478abe9484 --- /dev/null +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/TestPumpPlugin.kt @@ -0,0 +1,79 @@ +package info.nightscout.androidaps + +import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.data.DetailedBolusInfo +import info.nightscout.androidaps.data.Profile +import info.nightscout.androidaps.data.PumpEnactResult +import info.nightscout.androidaps.interfaces.PluginBase +import info.nightscout.androidaps.interfaces.PluginDescription +import info.nightscout.androidaps.interfaces.PumpDescription +import info.nightscout.androidaps.interfaces.PumpInterface +import info.nightscout.androidaps.logging.AAPSLogger +import info.nightscout.androidaps.plugins.common.ManufacturerType +import info.nightscout.androidaps.plugins.pump.common.defs.PumpType +import info.nightscout.androidaps.utils.TimeChangeType +import info.nightscout.androidaps.utils.resources.ResourceHelper +import org.json.JSONObject + +@Suppress("MemberVisibilityCanBePrivate") +class TestPumpPlugin(pluginDescription: PluginDescription, + aapsLogger: AAPSLogger, + resourceHelper: ResourceHelper, + injector: HasAndroidInjector +) : PluginBase( + pluginDescription, aapsLogger, resourceHelper, injector +), PumpInterface { + + var connected = false + var isProfileSet = true + var specialEnable = true + + override fun isConnected() = connected + override fun isConnecting() = false + override fun isHandshakeInProgress() = false + val lastData = 0L + + val baseBasal = 0.0 + override val pumpDescription = PumpDescription() + + override fun isInitialized(): Boolean = true + override fun isSuspended(): Boolean = false + override fun isBusy(): Boolean = false + override fun connect(reason: String) { + connected = true + } + + override fun disconnect(reason: String) { + connected = false + } + + override fun stopConnecting() { + connected = false + } + + override fun waitForDisconnectionInSeconds(): Int = 0 + override fun getPumpStatus(reason: String) {} + override fun setNewBasalProfile(profile: Profile): PumpEnactResult = PumpEnactResult(injector) + override fun isThisProfileSet(profile: Profile): Boolean = isProfileSet + override fun lastDataTime(): Long = lastData + override val baseBasalRate: Double = baseBasal + override val reservoirLevel: Double = 0.0 + override val batteryLevel: Int = 0 + override fun deliverTreatment(detailedBolusInfo: DetailedBolusInfo): PumpEnactResult = PumpEnactResult(injector).success(true) + override fun stopBolusDelivering() {} + override fun setTempBasalAbsolute(absoluteRate: Double, durationInMinutes: Int, profile: Profile, enforceNew: Boolean): PumpEnactResult = PumpEnactResult(injector).success(true) + override fun setTempBasalPercent(percent: Int, durationInMinutes: Int, profile: Profile, enforceNew: Boolean): PumpEnactResult = PumpEnactResult(injector).success(true) + override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult = PumpEnactResult(injector).success(true) + override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult = PumpEnactResult(injector).success(true) + override fun cancelExtendedBolus(): PumpEnactResult = PumpEnactResult(injector).success(true) + override fun getJSONStatus(profile: Profile, profileName: String, version: String): JSONObject = JSONObject() + override fun manufacturer(): ManufacturerType = ManufacturerType.AndroidAPS + override fun model(): PumpType = PumpType.GenericAAPS + override fun serialNumber(): String = "1" + override fun shortStatus(veryShort: Boolean): String = "" + override val isFakingTempsByExtendedBoluses: Boolean = false + override fun loadTDDs(): PumpEnactResult = PumpEnactResult(injector).success(true) + override fun canHandleDST(): Boolean = true + override fun timezoneOrDSTChanged(timeChangeType: TimeChangeType) {} + override fun specialEnableCondition(): Boolean = specialEnable +} \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionAlarmTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionAlarmTest.kt similarity index 98% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionAlarmTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionAlarmTest.kt index c17260f535..44cdb5d91a 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionAlarmTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionAlarmTest.kt @@ -3,8 +3,8 @@ package info.nightscout.androidaps.plugins.general.automation.actions import android.content.Context import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R import info.nightscout.androidaps.TestBase +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.automation.elements.InputString diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopDisableTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopDisableTest.kt similarity index 75% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopDisableTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopDisableTest.kt index a606f795db..ececed86fd 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopDisableTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopDisableTest.kt @@ -1,10 +1,9 @@ package info.nightscout.androidaps.plugins.general.automation.actions -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R +import info.nightscout.androidaps.interfaces.PluginBase import info.nightscout.androidaps.interfaces.PluginType import info.nightscout.androidaps.interfaces.PumpDescription -import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin import info.nightscout.androidaps.queue.Callback import org.junit.Assert import org.junit.Before @@ -13,7 +12,6 @@ import org.junit.runner.RunWith import org.mockito.ArgumentMatchers.eq import org.mockito.Mockito import org.mockito.Mockito.`when` -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) @@ -24,10 +22,7 @@ class ActionLoopDisableTest : ActionsTestBase() { @Before fun setup() { - `when`(virtualPumpPlugin.specialEnableCondition()).thenReturn(true) - val pumpDescription = PumpDescription().apply { isTempBasalCapable = true } - `when`(virtualPumpPlugin.pumpDescription).thenReturn(pumpDescription) - `when`(activePlugin.activePump).thenReturn(virtualPumpPlugin) + testPumpPlugin.pumpDescription.isTempBasalCapable = true `when`(resourceHelper.gs(R.string.disableloop)).thenReturn("Disable loop") `when`(resourceHelper.gs(R.string.alreadydisabled)).thenReturn("Disable loop") @@ -51,7 +46,7 @@ class ActionLoopDisableTest : ActionsTestBase() { @Test fun doActionTest() { - `when`(loopPlugin.isEnabled(PluginType.LOOP)).thenReturn(true) + `when`(loopPlugin.isEnabled()).thenReturn(true) sut.doAction(object : Callback() { override fun run() {} }) @@ -59,7 +54,7 @@ class ActionLoopDisableTest : ActionsTestBase() { Mockito.verify(configBuilderPlugin, Mockito.times(1)).storeSettings("ActionLoopDisable") Mockito.verify(commandQueue, Mockito.times(1)).cancelTempBasal(eq(true), anyObject()) - `when`(loopPlugin.isEnabled(PluginType.LOOP)).thenReturn(false) + `when`(loopPlugin.isEnabled()).thenReturn(false) // another call should keep it disabled, no new invocation sut.doAction(object : Callback() { diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopEnableTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopEnableTest.kt similarity index 70% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopEnableTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopEnableTest.kt index 64f545388c..9851c7b25f 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopEnableTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopEnableTest.kt @@ -1,10 +1,8 @@ package info.nightscout.androidaps.plugins.general.automation.actions -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R +import info.nightscout.androidaps.interfaces.PluginBase import info.nightscout.androidaps.interfaces.PluginType -import info.nightscout.androidaps.interfaces.PumpDescription -import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin import info.nightscout.androidaps.queue.Callback import org.junit.Assert import org.junit.Before @@ -12,7 +10,6 @@ import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mockito import org.mockito.Mockito.`when` -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) @@ -23,10 +20,7 @@ class ActionLoopEnableTest : ActionsTestBase() { @Before fun setup() { - `when`(virtualPumpPlugin.specialEnableCondition()).thenReturn(true) - val pumpDescription = PumpDescription().apply { isTempBasalCapable = true } - `when`(virtualPumpPlugin.pumpDescription).thenReturn(pumpDescription) - `when`(activePlugin.activePump).thenReturn(virtualPumpPlugin) + testPumpPlugin.pumpDescription.isTempBasalCapable = true `when`(resourceHelper.gs(R.string.enableloop)).thenReturn("Enable loop") `when`(resourceHelper.gs(R.string.alreadyenabled)).thenReturn("Already enabled") @@ -46,14 +40,14 @@ class ActionLoopEnableTest : ActionsTestBase() { } @Test fun doActionTest() { - `when`(loopPlugin.isEnabled(PluginType.LOOP)).thenReturn(false) + `when`(loopPlugin.isEnabled()).thenReturn(false) sut.doAction(object : Callback() { override fun run() {} }) Mockito.verify(loopPlugin, Mockito.times(1)).setPluginEnabled(PluginType.LOOP, true) Mockito.verify(configBuilderPlugin, Mockito.times(1)).storeSettings("ActionLoopEnable") - `when`(loopPlugin.isEnabled(PluginType.LOOP)).thenReturn(true) + `when`(loopPlugin.isEnabled()).thenReturn(true) // another call should keep it disabled, no new invocation sut.doAction(object : Callback() { diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopResumeTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopResumeTest.kt similarity index 94% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopResumeTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopResumeTest.kt index c7c9e3b6e6..f3f1a0f480 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopResumeTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopResumeTest.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.general.automation.actions -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.queue.Callback import org.junit.Assert import org.junit.Before @@ -18,7 +18,6 @@ class ActionLoopResumeTest : ActionsTestBase() { @Before fun setup() { - `when`(virtualPumpPlugin.specialEnableCondition()).thenReturn(true) `when`(resourceHelper.gs(R.string.resumeloop)).thenReturn("Resume loop") `when`(resourceHelper.gs(R.string.notsuspended)).thenReturn("Not suspended") diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopSuspendTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopSuspendTest.kt similarity index 92% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopSuspendTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopSuspendTest.kt index 2be1761970..bb21e9a89f 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopSuspendTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopSuspendTest.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.general.automation.actions -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.plugins.general.automation.elements.InputDuration import info.nightscout.androidaps.queue.Callback import org.junit.Assert @@ -20,8 +20,6 @@ class ActionLoopSuspendTest : ActionsTestBase() { @Before fun setup() { - `when`(virtualPumpPlugin.specialEnableCondition()).thenReturn(true) - `when`(activePlugin.activePump).thenReturn(virtualPumpPlugin) `when`(resourceHelper.gs(R.string.suspendloop)).thenReturn("Suspend loop") `when`(resourceHelper.gs(ArgumentMatchers.eq(R.string.suspendloopforXmin), ArgumentMatchers.anyInt())).thenReturn("Suspend loop for %d min") diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionNotificationTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionNotificationTest.kt similarity index 98% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionNotificationTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionNotificationTest.kt index 3ac32413ce..6e8af502b1 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionNotificationTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionNotificationTest.kt @@ -2,8 +2,8 @@ package info.nightscout.androidaps.plugins.general.automation.actions import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R import info.nightscout.androidaps.TestBase +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.automation.elements.InputString diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchPercentTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchPercentTest.kt similarity index 98% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchPercentTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchPercentTest.kt index d2b5180756..53b252ff3b 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchPercentTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchPercentTest.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.general.automation.actions -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.plugins.general.automation.elements.InputDuration import info.nightscout.androidaps.plugins.general.automation.elements.InputPercent import info.nightscout.androidaps.queue.Callback diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchTest.kt similarity index 88% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchTest.kt index f7e7c52f5a..f87a288b4b 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchTest.kt @@ -1,8 +1,7 @@ package info.nightscout.androidaps.plugins.general.automation.actions -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.plugins.general.automation.elements.InputProfileName -import info.nightscout.androidaps.plugins.profile.local.LocalProfilePlugin import info.nightscout.androidaps.queue.Callback import org.junit.Assert import org.junit.Before @@ -14,11 +13,9 @@ import org.mockito.Mockito import org.mockito.Mockito.`when` import org.mockito.Mockito.anyInt import org.mockito.Mockito.anyString -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest(LocalProfilePlugin::class) class ActionProfileSwitchTest : ActionsTestBase() { private lateinit var sut: ActionProfileSwitch @@ -75,8 +72,6 @@ class ActionProfileSwitchTest : ActionsTestBase() { }) // profile doesn't exists - `when`(activePlugin.activeProfileInterface).thenReturn(localProfilePlugin) - `when`(localProfilePlugin.profile).thenReturn(getValidProfileStore()) `when`(profileFunction.getProfileName()).thenReturn("Active") sut.inputProfileName = InputProfileName(injector, "Test") sut.doAction(object : Callback() { @@ -86,9 +81,7 @@ class ActionProfileSwitchTest : ActionsTestBase() { } }) - // do profileswitch - `when`(activePlugin.activeProfileInterface).thenReturn(localProfilePlugin) - `when`(localProfilePlugin.profile).thenReturn(getValidProfileStore()) + // do profile switch `when`(profileFunction.getProfileName()).thenReturn("Test") sut.inputProfileName = InputProfileName(injector, TESTPROFILENAME) sut.doAction(object : Callback() { diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionSendSMSTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionSendSMSTest.kt similarity index 95% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionSendSMSTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionSendSMSTest.kt index 0c1a9a1245..db8ead7126 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionSendSMSTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionSendSMSTest.kt @@ -1,7 +1,6 @@ package info.nightscout.androidaps.plugins.general.automation.actions -import android.widget.LinearLayout -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.plugins.general.automation.elements.InputString import info.nightscout.androidaps.queue.Callback import org.junit.Assert @@ -10,7 +9,6 @@ import org.junit.Test import org.junit.runner.RunWith import org.mockito.ArgumentMatchers.anyString import org.mockito.ArgumentMatchers.eq -import org.mockito.Mockito import org.mockito.Mockito.`when` import org.powermock.modules.junit4.PowerMockRunner diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStartTempTargetTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStartTempTargetTest.kt similarity index 93% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStartTempTargetTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStartTempTargetTest.kt index 5988e3519a..e7fde438bf 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStartTempTargetTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStartTempTargetTest.kt @@ -1,8 +1,7 @@ package info.nightscout.androidaps.plugins.general.automation.actions import info.nightscout.androidaps.Constants -import info.nightscout.androidaps.MainApp -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.plugins.general.automation.elements.InputDuration import info.nightscout.androidaps.plugins.general.automation.elements.InputTempTarget import info.nightscout.androidaps.queue.Callback @@ -12,11 +11,9 @@ import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mockito import org.mockito.Mockito.`when` -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest(MainApp::class) class ActionStartTempTargetTest : ActionsTestBase() { private lateinit var sut: ActionStartTempTarget diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStopTempTargetTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStopTempTargetTest.kt similarity index 90% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStopTempTargetTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStopTempTargetTest.kt index bf5ce1551e..b75cca3e2b 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStopTempTargetTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStopTempTargetTest.kt @@ -1,7 +1,6 @@ package info.nightscout.androidaps.plugins.general.automation.actions -import info.nightscout.androidaps.MainApp -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.queue.Callback import org.junit.Assert import org.junit.Before @@ -9,11 +8,9 @@ import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mockito import org.mockito.Mockito.`when` -import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest(MainApp::class) class ActionStopTempTargetTest : ActionsTestBase() { private lateinit var sut: ActionStopTempTarget diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionTest.kt similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionTest.kt diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionsTestBase.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionsTestBase.kt similarity index 68% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionsTestBase.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionsTestBase.kt index 7094f3f385..544ab63dff 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionsTestBase.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionsTestBase.kt @@ -4,33 +4,49 @@ import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.androidaps.Constants import info.nightscout.androidaps.TestBaseWithProfile +import info.nightscout.androidaps.TestPumpPlugin import info.nightscout.androidaps.data.PumpEnactResult -import info.nightscout.androidaps.interfaces.ActivePluginProvider -import info.nightscout.androidaps.interfaces.CommandQueueProvider -import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin +import info.nightscout.androidaps.interfaces.* +import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin import info.nightscout.androidaps.plugins.general.automation.elements.InputTempTarget -import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin -import info.nightscout.androidaps.plugins.profile.local.LocalProfilePlugin -import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin +import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP import org.junit.Before import org.mockito.Mock import org.mockito.Mockito.`when` import org.powermock.core.classloader.annotations.PrepareForTest -@PrepareForTest(VirtualPumpPlugin::class, RxBusWrapper::class, LocalProfilePlugin::class, SmsCommunicatorPlugin::class, ConfigBuilderPlugin::class, LoopPlugin::class) +@PrepareForTest(RxBusWrapper::class, ActionsTestBase.TestLoopPlugin::class) open class ActionsTestBase : TestBaseWithProfile() { + open class TestLoopPlugin( + aapsLogger: AAPSLogger, + resourceHelper: ResourceHelper, + injector: HasAndroidInjector, + pluginDescription: PluginDescription + ) : PluginBase( + pluginDescription, aapsLogger, resourceHelper, injector + ), LoopInterface { + + var suspended = false + override var lastRun: LoopInterface.LastRun? = LoopInterface.LastRun() + override val isSuspended: Boolean = suspended + override fun suspendTo(endTime: Long) {} + override fun createOfflineEvent(durationInMinutes: Int) {} + override fun suspendLoop(durationInMinutes: Int) {} + } + @Mock lateinit var sp: SP @Mock lateinit var commandQueue: CommandQueueProvider - @Mock lateinit var configBuilderPlugin: ConfigBuilderPlugin - @Mock lateinit var virtualPumpPlugin: VirtualPumpPlugin - @Mock lateinit var loopPlugin: LoopPlugin + @Mock lateinit var configBuilderPlugin: ConfigBuilderInterface @Mock lateinit var activePlugin: ActivePluginProvider - @Mock lateinit var localProfilePlugin: LocalProfilePlugin - @Mock lateinit var smsCommunicatorPlugin: SmsCommunicatorPlugin + @Mock lateinit var profilePlugin: ProfileInterface + @Mock lateinit var smsCommunicatorPlugin: SmsCommunicatorInterface + @Mock lateinit var loopPlugin: TestLoopPlugin + + private val pluginDescription = PluginDescription() + lateinit var testPumpPlugin: TestPumpPlugin var injector: HasAndroidInjector = HasAndroidInjector { AndroidInjector { @@ -99,6 +115,10 @@ open class ActionsTestBase : TestBaseWithProfile() { @Before fun mock() { + testPumpPlugin = TestPumpPlugin(pluginDescription, aapsLogger, resourceHelper, injector) + `when`(activePlugin.activePump).thenReturn(testPumpPlugin) `when`(profileFunction.getUnits()).thenReturn(Constants.MGDL) + `when`(activePlugin.activeProfileInterface).thenReturn(profilePlugin) + `when`(profilePlugin.profile).thenReturn(getValidProfileStore()) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/ComparatorConnectTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/ComparatorConnectTest.kt similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/ComparatorConnectTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/ComparatorConnectTest.kt diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/ComparatorExistsTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/ComparatorExistsTest.kt similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/ComparatorExistsTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/ComparatorExistsTest.kt diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/ComparatorTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/ComparatorTest.kt similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/ComparatorTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/ComparatorTest.kt diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/InputBgTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/InputBgTest.kt similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/InputBgTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/InputBgTest.kt diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDurationTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDurationTest.kt similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDurationTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDurationTest.kt diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/InputInsulinTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/InputInsulinTest.kt similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/InputInsulinTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/InputInsulinTest.kt diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/InputPercentTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/InputPercentTest.kt similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/InputPercentTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/InputPercentTest.kt diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/InputProfileNameTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/InputProfileNameTest.kt similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/InputProfileNameTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/InputProfileNameTest.kt diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/InputStringTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/InputStringTest.kt similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/InputStringTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/InputStringTest.kt diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTempTargetTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTempTargetTest.kt similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTempTargetTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTempTargetTest.kt diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/LabelWithElementTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/LabelWithElementTest.kt similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/LabelWithElementTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/LabelWithElementTest.kt diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/LayoutBuilderTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/LayoutBuilderTest.kt similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/LayoutBuilderTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/LayoutBuilderTest.kt diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/StaticLabelTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/StaticLabelTest.kt similarity index 94% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/StaticLabelTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/StaticLabelTest.kt index 4b85698d3c..d40b5243e3 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/StaticLabelTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/elements/StaticLabelTest.kt @@ -1,6 +1,6 @@ package info.nightscout.androidaps.plugins.general.automation.elements -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerDummy import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerTestBase import org.junit.Assert diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/DummyTrigger.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/DummyTrigger.kt similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/DummyTrigger.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/DummyTrigger.kt diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerAutosensValueTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerAutosensValueTest.kt similarity index 96% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerAutosensValueTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerAutosensValueTest.kt index 54c4381923..27b040ad3b 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerAutosensValueTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerAutosensValueTest.kt @@ -1,10 +1,9 @@ package info.nightscout.androidaps.plugins.general.automation.triggers import com.google.common.base.Optional -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.plugins.general.automation.elements.Comparator import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.androidaps.utils.DateUtil import org.json.JSONObject import org.junit.Assert @@ -19,7 +18,7 @@ import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest(DateUtil::class, IobCobCalculatorPlugin::class) +@PrepareForTest(DateUtil::class) class TriggerAutosensValueTest : TriggerTestBase() { var now = 1514766900000L diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBTDeviceTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBTDeviceTest.kt similarity index 97% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBTDeviceTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBTDeviceTest.kt index d2d3d77168..8cd9a57ab8 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBTDeviceTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBTDeviceTest.kt @@ -1,7 +1,7 @@ package info.nightscout.androidaps.plugins.general.automation.triggers import com.google.common.base.Optional -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.plugins.general.automation.elements.ComparatorConnect import org.json.JSONObject import org.junit.Assert diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBgTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBgTest.kt similarity index 95% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBgTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBgTest.kt index 430568c484..41cdcc851a 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBgTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBgTest.kt @@ -2,11 +2,10 @@ package info.nightscout.androidaps.plugins.general.automation.triggers import com.google.common.base.Optional import info.nightscout.androidaps.Constants -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.database.entities.GlucoseValue import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.general.automation.elements.Comparator -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.androidaps.utils.DateUtil import org.json.JSONObject import org.junit.Assert @@ -20,7 +19,7 @@ import org.powermock.modules.junit4.PowerMockRunner import java.util.* @RunWith(PowerMockRunner::class) -@PrepareForTest(DateUtil::class, IobCobCalculatorPlugin::class, ProfileFunction::class) +@PrepareForTest(DateUtil::class, ProfileFunction::class) class TriggerBgTest : TriggerTestBase() { var now = 1514766900000L diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBolusAgoTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBolusAgoTest.kt similarity index 96% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBolusAgoTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBolusAgoTest.kt index ad087bf69c..1394801ce1 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBolusAgoTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBolusAgoTest.kt @@ -1,9 +1,8 @@ package info.nightscout.androidaps.plugins.general.automation.triggers import com.google.common.base.Optional -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.plugins.general.automation.elements.Comparator -import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin import info.nightscout.androidaps.utils.DateUtil import org.json.JSONException import org.json.JSONObject @@ -17,7 +16,7 @@ import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest(DateUtil::class, TreatmentsPlugin::class) +@PrepareForTest(DateUtil::class) class TriggerBolusAgoTest : TriggerTestBase() { var now = 1514766900000L diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerCOBTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerCOBTest.kt similarity index 94% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerCOBTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerCOBTest.kt index 0c2a942a3e..ae14c4db6d 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerCOBTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerCOBTest.kt @@ -1,10 +1,9 @@ package info.nightscout.androidaps.plugins.general.automation.triggers import com.google.common.base.Optional -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.plugins.general.automation.elements.Comparator import info.nightscout.androidaps.plugins.iob.iobCobCalculator.CobInfo -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.androidaps.utils.DateUtil import org.json.JSONObject import org.junit.Assert @@ -17,7 +16,7 @@ import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest(DateUtil::class, IobCobCalculatorPlugin::class) +@PrepareForTest(DateUtil::class) class TriggerCOBTest : TriggerTestBase() { var now = 1514766900000L diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerConnectorTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerConnectorTest.kt similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerConnectorTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerConnectorTest.kt diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerDeltaTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerDeltaTest.kt similarity index 97% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerDeltaTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerDeltaTest.kt index 977b740320..9636d999bd 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerDeltaTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerDeltaTest.kt @@ -2,12 +2,11 @@ package info.nightscout.androidaps.plugins.general.automation.triggers import com.google.common.base.Optional import info.nightscout.androidaps.Constants -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.database.entities.GlucoseValue import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.general.automation.elements.Comparator import info.nightscout.androidaps.plugins.general.automation.elements.InputDelta.DeltaType -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.androidaps.utils.DateUtil import org.json.JSONObject import org.junit.Assert @@ -21,7 +20,7 @@ import org.powermock.modules.junit4.PowerMockRunner import java.util.* @RunWith(PowerMockRunner::class) -@PrepareForTest(DateUtil::class, IobCobCalculatorPlugin::class, ProfileFunction::class) +@PrepareForTest(DateUtil::class, ProfileFunction::class) class TriggerDeltaTest : TriggerTestBase() { var now = 1514766900000L diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerIobTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerIobTest.kt similarity index 95% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerIobTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerIobTest.kt index 7df8805f20..8a2961bc17 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerIobTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerIobTest.kt @@ -1,11 +1,10 @@ package info.nightscout.androidaps.plugins.general.automation.triggers import com.google.common.base.Optional -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.data.IobTotal import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.plugins.general.automation.elements.Comparator -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.androidaps.utils.DateUtil import org.json.JSONObject import org.junit.Assert @@ -19,7 +18,7 @@ import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest(DateUtil::class, IobCobCalculatorPlugin::class) +@PrepareForTest(DateUtil::class) class TriggerIobTest : TriggerTestBase() { var now = 1514766900000L diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerLocationTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerLocationTest.kt similarity index 99% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerLocationTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerLocationTest.kt index 30e6081b29..3fa5319d88 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerLocationTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerLocationTest.kt @@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.general.automation.triggers import android.location.Location import com.google.common.base.Optional -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.plugins.general.automation.elements.InputLocationMode import info.nightscout.androidaps.services.LocationService import info.nightscout.androidaps.utils.DateUtil diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerProfilePercentTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerProfilePercentTest.kt similarity index 98% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerProfilePercentTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerProfilePercentTest.kt index eccbf1a3e2..896e036c3a 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerProfilePercentTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerProfilePercentTest.kt @@ -1,7 +1,7 @@ package info.nightscout.androidaps.plugins.general.automation.triggers import com.google.common.base.Optional -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.plugins.general.automation.elements.Comparator import info.nightscout.androidaps.utils.DateUtil import org.json.JSONException diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerPumpLastConnectionTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerPumpLastConnectionTest.kt similarity index 89% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerPumpLastConnectionTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerPumpLastConnectionTest.kt index 692143d7e2..3c3d5f131b 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerPumpLastConnectionTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerPumpLastConnectionTest.kt @@ -1,26 +1,22 @@ package info.nightscout.androidaps.plugins.general.automation.triggers import com.google.common.base.Optional -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.plugins.general.automation.elements.Comparator -import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin import info.nightscout.androidaps.utils.DateUtil import org.json.JSONObject import org.junit.Assert import org.junit.Before import org.junit.Test import org.junit.runner.RunWith -import org.mockito.Mock import org.powermock.api.mockito.PowerMockito import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest(DateUtil::class, VirtualPumpPlugin::class) +@PrepareForTest(DateUtil::class) class TriggerPumpLastConnectionTest : TriggerTestBase() { - @Mock lateinit var virtualPumpPlugin: VirtualPumpPlugin - var now = 1514766900000L @Before @@ -33,8 +29,7 @@ class TriggerPumpLastConnectionTest : TriggerTestBase() { fun shouldRunTest() { // System.currentTimeMillis() is always 0 // and so is every last connection time - PowerMockito.`when`(activePlugin.activePump).thenReturn(virtualPumpPlugin) - Assert.assertEquals(0L, virtualPumpPlugin.lastDataTime()) + Assert.assertEquals(0L, testPumpPlugin.lastDataTime()) PowerMockito.`when`(DateUtil.now()).thenReturn(now + 10 * 60 * 1000) // set current time to now + 10 min var t = TriggerPumpLastConnection(injector).setValue(110).comparator(Comparator.Compare.IS_EQUAL) Assert.assertEquals(110, t.minutesAgo.value) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTimeTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTimeTest.kt similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTimeTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTimeTest.kt diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTempTargetTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTempTargetTest.kt similarity index 94% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTempTargetTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTempTargetTest.kt index a37108d6f6..441b1dd58d 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTempTargetTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTempTargetTest.kt @@ -1,10 +1,9 @@ package info.nightscout.androidaps.plugins.general.automation.triggers import com.google.common.base.Optional -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.db.TempTarget import info.nightscout.androidaps.plugins.general.automation.elements.ComparatorExists -import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin import info.nightscout.androidaps.utils.DateUtil import org.json.JSONObject import org.junit.Assert @@ -17,7 +16,7 @@ import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest(DateUtil::class, TreatmentsPlugin::class) +@PrepareForTest(DateUtil::class) class TriggerTempTargetTest : TriggerTestBase() { var now = 1514766900000L diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTestBase.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTestBase.kt similarity index 84% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTestBase.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTestBase.kt index f439403553..02d0cd15a0 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTestBase.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTestBase.kt @@ -4,36 +4,44 @@ import android.content.Context import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.androidaps.TestBaseWithProfile +import info.nightscout.androidaps.TestPumpPlugin import info.nightscout.androidaps.interfaces.ActivePluginProvider +import info.nightscout.androidaps.interfaces.IobCobCalculatorInterface +import info.nightscout.androidaps.interfaces.PluginDescription import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.automation.AutomationPlugin import info.nightscout.androidaps.plugins.general.automation.elements.InputBg import info.nightscout.androidaps.plugins.general.automation.elements.InputTempTarget import info.nightscout.androidaps.plugins.general.automation.elements.StaticLabel import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.androidaps.receivers.ReceiverStatusStore import info.nightscout.androidaps.services.LastLocationDataContainer import info.nightscout.androidaps.utils.sharedPreferences.SP import org.junit.Before import org.mockito.Mock +import org.mockito.Mockito.`when` +import org.powermock.api.mockito.PowerMockito import org.powermock.core.classloader.annotations.PrepareForTest -@PrepareForTest(LastLocationDataContainer::class, AutomationPlugin::class, IobCobCalculatorPlugin::class) +@PrepareForTest(LastLocationDataContainer::class, AutomationPlugin::class) open class TriggerTestBase : TestBaseWithProfile() { @Mock lateinit var sp: SP @Mock lateinit var locationDataContainer: LastLocationDataContainer @Mock lateinit var activePlugin: ActivePluginProvider - @Mock lateinit var iobCobCalculatorPlugin: IobCobCalculatorPlugin + @Mock lateinit var iobCobCalculatorPlugin: IobCobCalculatorInterface @Mock lateinit var context: Context @Mock lateinit var automationPlugin: AutomationPlugin lateinit var receiverStatusStore: ReceiverStatusStore + private val pluginDescription = PluginDescription() + lateinit var testPumpPlugin : TestPumpPlugin @Before fun prepareMock1() { receiverStatusStore = ReceiverStatusStore(context, rxBus) + testPumpPlugin = TestPumpPlugin(pluginDescription, aapsLogger, resourceHelper, injector) + `when`(activePlugin.activePump).thenReturn(testPumpPlugin) } var injector: HasAndroidInjector = HasAndroidInjector { diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeRangeTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeRangeTest.kt similarity index 98% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeRangeTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeRangeTest.kt index dba3ddce80..af5a9ea355 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeRangeTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeRangeTest.kt @@ -1,7 +1,7 @@ package info.nightscout.androidaps.plugins.general.automation.triggers import com.google.common.base.Optional -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.MidnightTime import org.json.JSONObject diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeTest.kt similarity index 98% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeTest.kt index e5b993c193..db6a2dd645 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeTest.kt @@ -1,7 +1,7 @@ package info.nightscout.androidaps.plugins.general.automation.triggers import com.google.common.base.Optional -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.T import org.json.JSONException diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerWifiSsidTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerWifiSsidTest.kt similarity index 98% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerWifiSsidTest.kt rename to automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerWifiSsidTest.kt index 7dcdac3ea4..9cd013008a 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerWifiSsidTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerWifiSsidTest.kt @@ -1,7 +1,7 @@ package info.nightscout.androidaps.plugins.general.automation.triggers import com.google.common.base.Optional -import info.nightscout.androidaps.R +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.events.EventNetworkChange import info.nightscout.androidaps.plugins.general.automation.elements.Comparator import info.nightscout.androidaps.receivers.NetworkChangeReceiver diff --git a/core/src/androidTest/java/info/nightscout/androidaps/core/ExampleInstrumentedTest.kt b/core/src/androidTest/java/info/nightscout/androidaps/core/ExampleInstrumentedTest.kt deleted file mode 100644 index f0f2aec62c..0000000000 --- a/core/src/androidTest/java/info/nightscout/androidaps/core/ExampleInstrumentedTest.kt +++ /dev/null @@ -1,25 +0,0 @@ -package info.nightscout.androidaps.core - -import androidx.test.platform.app.InstrumentationRegistry -import androidx.test.ext.junit.runners.AndroidJUnit4 - -import org.junit.Test -import org.junit.runner.RunWith - -import org.junit.Assert.* - -/** - * Instrumented test, which will execute on an Android device. - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -@RunWith(AndroidJUnit4::class) -class ExampleInstrumentedTest { - - @Test - fun useAppContext() { - // Context of the app under test. - val appContext = InstrumentationRegistry.getInstrumentation().targetContext - assertEquals("info.nightscout.androidaps.core.test", appContext.packageName) - } -} diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/DialogFragmentWithDate.kt b/core/src/main/java/info/nightscout/androidaps/dialogs/DialogFragmentWithDate.kt similarity index 99% rename from app/src/main/java/info/nightscout/androidaps/dialogs/DialogFragmentWithDate.kt rename to core/src/main/java/info/nightscout/androidaps/dialogs/DialogFragmentWithDate.kt index f2980a9b65..89b1827c1d 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/DialogFragmentWithDate.kt +++ b/core/src/main/java/info/nightscout/androidaps/dialogs/DialogFragmentWithDate.kt @@ -12,7 +12,7 @@ import android.widget.Button import android.widget.TextView import androidx.fragment.app.FragmentManager import dagger.android.support.DaggerDialogFragment -import info.nightscout.androidaps.R +import info.nightscout.androidaps.core.R import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.utils.DateUtil diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/events/EventAutosensCalculationFinished.kt b/core/src/main/java/info/nightscout/androidaps/events/EventAutosensCalculationFinished.kt similarity index 70% rename from app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/events/EventAutosensCalculationFinished.kt rename to core/src/main/java/info/nightscout/androidaps/events/EventAutosensCalculationFinished.kt index aa96aaf0b0..3c6073d9f0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/events/EventAutosensCalculationFinished.kt +++ b/core/src/main/java/info/nightscout/androidaps/events/EventAutosensCalculationFinished.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.iob.iobCobCalculator.events +package info.nightscout.androidaps.events import info.nightscout.androidaps.events.Event import info.nightscout.androidaps.events.EventLoop diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/IconsProviderInterface.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/IconsProviderInterface.kt new file mode 100644 index 0000000000..899aed4e59 --- /dev/null +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/IconsProviderInterface.kt @@ -0,0 +1,6 @@ +package info.nightscout.androidaps.interfaces + +interface IconsProviderInterface { + fun getIcon(): Int + fun getNotificationIcon(): Int +} \ No newline at end of file diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/IobCobCalculatorInterface.java b/core/src/main/java/info/nightscout/androidaps/interfaces/IobCobCalculatorInterface.java deleted file mode 100644 index 75a57b2c07..0000000000 --- a/core/src/main/java/info/nightscout/androidaps/interfaces/IobCobCalculatorInterface.java +++ /dev/null @@ -1,14 +0,0 @@ -package info.nightscout.androidaps.interfaces; - -import androidx.collection.LongSparseArray; - -import info.nightscout.androidaps.data.IobTotal; -import info.nightscout.androidaps.data.Profile; -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData; - -public interface IobCobCalculatorInterface { - LongSparseArray getAutosensDataTable(); - IobTotal[] calculateIobArrayInDia(Profile profile); - String lastDataTime(); - AutosensData getAutosensData(long toTime); -} diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/IobCobCalculatorInterface.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/IobCobCalculatorInterface.kt new file mode 100644 index 0000000000..740c19101f --- /dev/null +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/IobCobCalculatorInterface.kt @@ -0,0 +1,22 @@ +package info.nightscout.androidaps.interfaces + +import androidx.collection.LongSparseArray +import info.nightscout.androidaps.data.IobTotal +import info.nightscout.androidaps.data.Profile +import info.nightscout.androidaps.database.entities.GlucoseValue +import info.nightscout.androidaps.plugins.iob.iobCobCalculator.CobInfo +import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData + +interface IobCobCalculatorInterface { + + val dataLock: Any + var bgReadings: List + + fun getAutosensDataTable(): LongSparseArray + fun calculateIobArrayInDia(profile: Profile): Array + fun lastDataTime(): String + fun getAutosensData(fromTime: Long): AutosensData? + fun getLastAutosensData(reason: String): AutosensData? + fun getCobInfo(_synchronized: Boolean, reason: String): CobInfo + fun calculateFromTreatmentsAndTempsSynchronized(time: Long, profile: Profile?): IobTotal +} \ No newline at end of file diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/LoopInterface.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/LoopInterface.kt index 2ec67b461b..1aac4769b2 100644 --- a/core/src/main/java/info/nightscout/androidaps/interfaces/LoopInterface.kt +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/LoopInterface.kt @@ -21,4 +21,9 @@ interface LoopInterface { } var lastRun: LastRun? + val isSuspended: Boolean + + fun suspendTo(endTime: Long) + fun createOfflineEvent(durationInMinutes: Int) + fun suspendLoop(durationInMinutes: Int) } \ No newline at end of file diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/NotificationHolderInterface.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/NotificationHolderInterface.kt index cbba8f326a..81e4b75503 100644 --- a/core/src/main/java/info/nightscout/androidaps/interfaces/NotificationHolderInterface.kt +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/NotificationHolderInterface.kt @@ -1,10 +1,13 @@ package info.nightscout.androidaps.interfaces import android.app.Notification +import android.app.PendingIntent +import android.content.Context interface NotificationHolderInterface { val channelID : String val notificationID : Int var notification: Notification + fun openAppIntent(context: Context): PendingIntent? } \ No newline at end of file diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/PluginBase.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/PluginBase.kt index 59e8c07c76..b560353b3a 100644 --- a/core/src/main/java/info/nightscout/androidaps/interfaces/PluginBase.kt +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/PluginBase.kt @@ -48,7 +48,7 @@ abstract class PluginBase( open val preferencesId: Int get() = pluginDescription.preferencesId - fun isEnabled() = isEnabled(pluginDescription.mainType) + open fun isEnabled() = isEnabled(pluginDescription.mainType) fun isEnabled(type: PluginType): Boolean { if (pluginDescription.alwaysEnabled && type == pluginDescription.mainType) return true diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/SmsCommunicatorInterface.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/SmsCommunicatorInterface.kt new file mode 100644 index 0000000000..9e201728ec --- /dev/null +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/SmsCommunicatorInterface.kt @@ -0,0 +1,6 @@ +package info.nightscout.androidaps.interfaces + +interface SmsCommunicatorInterface { + + fun sendNotificationToAllNumbers(text: String): Boolean +} \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationUserMessage.kt b/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationUserMessage.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationUserMessage.kt rename to core/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationUserMessage.kt diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationWithAction.kt b/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationWithAction.kt new file mode 100644 index 0000000000..2effa44c0e --- /dev/null +++ b/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationWithAction.kt @@ -0,0 +1,2 @@ +package info.nightscout.androidaps.plugins.general.overview.notifications + diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/CobInfo.kt b/core/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/CobInfo.kt similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/CobInfo.kt rename to core/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/CobInfo.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/GlucoseStatus.kt b/core/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/GlucoseStatus.kt similarity index 98% rename from app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/GlucoseStatus.kt rename to core/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/GlucoseStatus.kt index d6a6c1ff7a..80b6deb2a4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/GlucoseStatus.kt +++ b/core/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/GlucoseStatus.kt @@ -1,6 +1,7 @@ package info.nightscout.androidaps.plugins.iob.iobCobCalculator import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.interfaces.IobCobCalculatorInterface import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.utils.DateUtil @@ -13,7 +14,7 @@ import kotlin.math.roundToLong class GlucoseStatus(private val injector: HasAndroidInjector) { @Inject lateinit var aapsLogger: AAPSLogger - @Inject lateinit var iobCobCalculatorPlugin: IobCobCalculatorPlugin + @Inject lateinit var iobCobCalculatorPlugin: IobCobCalculatorInterface var glucose = 0.0 var noise = 0.0 diff --git a/app/src/main/java/info/nightscout/androidaps/utils/MidnightTime.java b/core/src/main/java/info/nightscout/androidaps/utils/MidnightTime.java similarity index 100% rename from app/src/main/java/info/nightscout/androidaps/utils/MidnightTime.java rename to core/src/main/java/info/nightscout/androidaps/utils/MidnightTime.java diff --git a/app/src/main/java/info/nightscout/androidaps/utils/TimerUtil.kt b/core/src/main/java/info/nightscout/androidaps/utils/TimerUtil.kt similarity index 95% rename from app/src/main/java/info/nightscout/androidaps/utils/TimerUtil.kt rename to core/src/main/java/info/nightscout/androidaps/utils/TimerUtil.kt index b62f00df54..054064efe0 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/TimerUtil.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/TimerUtil.kt @@ -3,7 +3,7 @@ package info.nightscout.androidaps.utils import android.content.Context import android.content.Intent import android.provider.AlarmClock -import info.nightscout.androidaps.R +import info.nightscout.androidaps.core.R import info.nightscout.androidaps.utils.resources.ResourceHelper import javax.inject.Inject import javax.inject.Singleton diff --git a/app/src/main/res/drawable/ic_access_alarm_24dp.xml b/core/src/main/res/drawable/ic_access_alarm_24dp.xml similarity index 100% rename from app/src/main/res/drawable/ic_access_alarm_24dp.xml rename to core/src/main/res/drawable/ic_access_alarm_24dp.xml diff --git a/app/src/main/res/drawable/ic_add.xml b/core/src/main/res/drawable/ic_add.xml similarity index 100% rename from app/src/main/res/drawable/ic_add.xml rename to core/src/main/res/drawable/ic_add.xml diff --git a/app/src/main/res/drawable/ic_bolus.xml b/core/src/main/res/drawable/ic_bolus.xml similarity index 100% rename from app/src/main/res/drawable/ic_bolus.xml rename to core/src/main/res/drawable/ic_bolus.xml diff --git a/app/src/main/res/drawable/ic_clone.xml b/core/src/main/res/drawable/ic_clone.xml similarity index 100% rename from app/src/main/res/drawable/ic_clone.xml rename to core/src/main/res/drawable/ic_clone.xml diff --git a/app/src/main/res/drawable/ic_cp_bgcheck.xml b/core/src/main/res/drawable/ic_cp_bgcheck.xml similarity index 100% rename from app/src/main/res/drawable/ic_cp_bgcheck.xml rename to core/src/main/res/drawable/ic_cp_bgcheck.xml diff --git a/app/src/main/res/drawable/ic_cp_bolus_carbs.xml b/core/src/main/res/drawable/ic_cp_bolus_carbs.xml similarity index 100% rename from app/src/main/res/drawable/ic_cp_bolus_carbs.xml rename to core/src/main/res/drawable/ic_cp_bolus_carbs.xml diff --git a/app/src/main/res/drawable/ic_notif_aaps.xml b/core/src/main/res/drawable/ic_notif_aaps.xml similarity index 100% rename from app/src/main/res/drawable/ic_notif_aaps.xml rename to core/src/main/res/drawable/ic_notif_aaps.xml diff --git a/app/src/main/res/drawable/ic_remove.xml b/core/src/main/res/drawable/ic_remove.xml similarity index 100% rename from app/src/main/res/drawable/ic_remove.xml rename to core/src/main/res/drawable/ic_remove.xml diff --git a/app/src/main/res/drawable/ic_temptarget_high.xml b/core/src/main/res/drawable/ic_temptarget_high.xml similarity index 100% rename from app/src/main/res/drawable/ic_temptarget_high.xml rename to core/src/main/res/drawable/ic_temptarget_high.xml diff --git a/app/src/main/res/layout/datetime.xml b/core/src/main/res/layout/datetime.xml similarity index 100% rename from app/src/main/res/layout/datetime.xml rename to core/src/main/res/layout/datetime.xml diff --git a/app/src/main/res/layout/notes.xml b/core/src/main/res/layout/notes.xml similarity index 100% rename from app/src/main/res/layout/notes.xml rename to core/src/main/res/layout/notes.xml diff --git a/core/src/main/res/values/colors.xml b/core/src/main/res/values/colors.xml index cea8a79521..4685b9e98b 100644 --- a/core/src/main/res/values/colors.xml +++ b/core/src/main/res/values/colors.xml @@ -9,6 +9,7 @@ #808080 #d8d8d8 #121212 + #66000000 #00695c @@ -41,6 +42,7 @@ #00d2d2 #ffffff + #5a595b #D000FF00 #1ea3e5 #1e88e5 @@ -89,5 +91,10 @@ #BBBBBB #FFFFFF + #f4d700 + #ff0400 + #FFFFFF + #303030 + #77dd77 diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index 04c79461f2..29817b9daa 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -30,6 +30,10 @@ virtualpump_type QuickWizard wearcontrol + show_notes_entry_dialogs + autosens_max + autosens_min + treatmentssafety_maxcarbs Refresh @@ -110,6 +114,29 @@ Pump time updated Exit Serial number + Remove record + Loop is disabled + Alarm + Disable loop + Enable loop + Resume loop + Suspend loop + Duration [min] + Notification + No profile loaded from NS yet + exists + not exists + Glucose + IOB + COB + Name: + Time + WiFi SSID + Loading … + Event time + Notes + Remove + Add new Limiting max basal rate to %1$.2f U/h because of %2$s diff --git a/crowdin.yml b/crowdin.yml index 02aa694983..2d2fcb108d 100644 --- a/crowdin.yml +++ b/crowdin.yml @@ -29,3 +29,5 @@ files: translation: /insight/src/main/res/values-%android_code%/strings.xml - source: /insigt/src/main/res/values/insight_*.xml translation: /insigt/src/main/res/values-%android_code%/%original_file_name% + - source: /automation/src/main/res/values/strings.xml + translation: /automation/src/main/res/values-%android_code%/strings.xml diff --git a/settings.gradle b/settings.gradle index fcdbd94eb0..f3a9b4faaa 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1,4 @@ +include ':automation' include ':insight' include ':app' include ':wear'