From d108755814ef36600edfcfc85ea278fda2baef4b Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 11 Nov 2022 17:46:09 +0100 Subject: [PATCH] move to plugins module --- .idea/dictionaries/project_dictionary.xml | 15 ++ .../nightscout/rx/events/EventSWUpdate.kt | 3 + app/build.gradle | 3 - .../activities/MyPreferenceFragment.kt | 2 +- .../nightscout/androidaps/di/AppComponent.kt | 3 +- .../androidaps/di/FragmentsModule.kt | 8 +- .../androidaps/di/ObjectivesModule.kt | 21 -- .../androidaps/di/PluginsListModule.kt | 6 +- .../info/nightscout/androidaps/di/UIModule.kt | 2 +- .../implementations/ActivityNamesImpl.kt | 40 ++- .../aps/openAPSAMA/OpenAPSAMAPlugin.kt | 15 +- .../aps/openAPSSMB/OpenAPSSMBPlugin.kt | 9 + .../general/overview/OverviewFragment.kt | 5 +- .../wear/wearintegration/DataHandlerMobile.kt | 2 +- .../sensitivity/SensitivityOref1Plugin.kt | 9 +- .../androidaps/setupwizard/SWDefinition.kt | 6 +- .../setupwizard/SetupWizardActivity.kt | 2 +- .../androidaps/setupwizard/elements/SWItem.kt | 2 +- .../setupwizard/elements/SWPlugin.kt | 2 +- .../setupwizard/events/EventSWUpdate.kt | 5 - .../nightscout/androidaps/utils/SntpClient.kt | 199 +-------------- app/src/main/res/menu/menu_main.xml | 2 +- app/src/main/res/values/arrays.xml | 15 -- app/src/main/res/values/exam.xml | 227 ----------------- app/src/main/res/values/objectives.xml | 59 ----- app/src/main/res/values/strings.xml | 96 -------- app/src/main/res/xml/pref_general.xml | 2 +- .../interfaces/ConstraintsCheckerTest.kt | 27 +- .../safety/SafetyPluginTest.kt | 103 +++++--- .../androidaps/utils/SntpClientTest.kt | 1 + .../actions/ActionStartTempTarget.kt | 2 +- .../automation/triggers/TriggerTempTarget.kt | 4 +- .../androidaps/data/PumpEnactResultObject.kt | 4 +- .../androidaps/plugins/aps/loop/APSResult.kt | 4 +- .../nightscout/androidaps/utils/Translator.kt | 6 +- .../userEntry/UserEntryPresentationHelper.kt | 2 +- ...al.xml => ic_actions_start_temp_basal.xml} | 0 .../src/main/res/drawable/ic_clone_48.xml | 0 .../src/main/res/drawable/ic_xdrip.xml | 0 .../core-main/src/main/res/values/strings.xml | 8 +- .../androidaps/data/PumpEnactResultTest.kt | 2 +- .../info/nightscout/interfaces/pump/Pump.kt | 4 + .../nightscout/interfaces/ui/ActivityNames.kt | 19 +- plugins/build.gradle | 5 + .../objectives/ObjectivesFragment.kt | 19 +- .../objectives/ObjectivesPlugin.kt | 26 +- .../constraints/objectives/SntpClient.kt | 200 +++++++++++++++ .../activities/ObjectivesExamDialog.kt | 22 +- .../objectives/dialogs/NtpProgressDialog.kt | 2 +- .../events/EventObjectivesUpdateGui.kt | 2 +- .../objectives/objectives/Objective.kt | 4 +- .../objectives/objectives/Objective0.kt | 4 +- .../objectives/objectives/Objective1.kt | 6 +- .../objectives/objectives/Objective10.kt | 4 +- .../objectives/objectives/Objective2.kt | 6 +- .../objectives/objectives/Objective3.kt | 4 +- .../objectives/objectives/Objective4.kt | 4 +- .../objectives/objectives/Objective5.kt | 6 +- .../objectives/objectives/Objective6.kt | 6 +- .../objectives/objectives/Objective7.kt | 4 +- .../objectives/objectives/Objective9.kt | 4 +- .../objectives/objectives/SntpClient.kt | 2 + .../constraints/safety/SafetyPlugin.kt | 20 +- .../nightscout/plugins/di/ObjectivesModule.kt | 33 +++ .../nightscout/plugins/di/PluginsModule.kt | 4 +- .../nightscout/plugins}/di/SkinsModule.kt | 12 +- .../general/actions/ActionsFragment.kt | 51 ++-- .../plugins/general/actions/ActionsPlugin.kt | 20 +- .../plugins}/skins/SkinButtonsOn.kt | 4 +- .../nightscout/plugins}/skins/SkinClassic.kt | 8 +- .../plugins}/skins/SkinInterface.kt | 8 +- .../plugins}/skins/SkinLargeDisplay.kt | 8 +- .../plugins}/skins/SkinListPreference.kt | 2 +- .../nightscout/plugins}/skins/SkinLowRes.kt | 16 +- .../nightscout/plugins}/skins/SkinProvider.kt | 6 +- .../plugins/ui}/StatusLightHandler.kt | 13 +- .../ic_actions_cancel_extended_bolus.xml | 0 .../ic_arrow_drop_down_white_24dp.xml | 0 .../src/main/res/drawable/ic_cancel_basal.xml | 0 .../main/res/drawable/ic_cp_age_battery.xml | 0 .../main/res/drawable/ic_cp_age_cannula.xml | 0 .../main/res/drawable/ic_cp_age_insulin.xml | 0 .../main/res/drawable/ic_cp_age_sensor.xml | 0 .../src/main/res/drawable/ic_crosstarget.xml | 0 .../src/main/res/layout/actions_fragment.xml | 28 +-- .../res/layout/actions_stats_fragment.xml | 22 +- .../res/layout/objectives_exam_fragment.xml | 10 +- .../main/res/layout/objectives_fragment.xml | 2 +- .../src/main/res/layout/objectives_item.xml | 0 .../res/layout/overview_buttons_layout.xml | 0 .../src/main/res/layout/overview_fragment.xml | 2 +- .../res/layout/overview_graphs_layout.xml | 0 .../main/res/layout/overview_info_layout.xml | 0 .../layout/overview_statuslights_layout.xml | 2 +- plugins/src/main/res/values/arrays.xml | 15 ++ plugins/src/main/res/values/exam.xml | 230 ++++++++++++++++++ plugins/src/main/res/values/objectives.xml | 62 +++++ plugins/src/main/res/values/strings.xml | 101 +++++++- .../src/main/res/xml/pref_safety.xml | 0 .../nightscout/androidaps/HardLimitsMock.kt | 84 +++++++ .../objectives/ObjectivesPluginTest.kt | 19 +- .../SmsCommunicatorPluginTest.kt | 2 +- .../plugins/source/GlimpPluginTest.kt | 0 .../plugins/source/MM640GPluginTest.kt | 0 .../plugins/source/NSClientPluginTest.kt | 0 .../plugins/source/XdripPluginTest.kt | 0 .../omnipod/eros/OmnipodErosPumpPlugin.java | 1 + .../fragments/TreatmentsTempTargetFragment.kt | 2 +- .../info/nightscout/ui/dialogs/CareDialog.kt | 99 ++++---- .../ui/dialogs/ProfileSwitchDialog.kt | 2 +- .../nightscout/ui/dialogs/TempTargetDialog.kt | 2 +- .../main/res/drawable/cb_background_bg.xml | 14 +- .../main/res/drawable/cb_background_cob.xml | 14 +- .../main/res/drawable/cb_background_iob.xml | 14 +- .../main/res/drawable/cb_background_trend.xml | 14 +- .../main/res/drawable/cb_background_tt.xml | 0 .../main/res/drawable/checkbox_bg_icon.xml | 8 +- .../main/res/drawable/checkbox_cob_icon.xml | 8 +- .../main/res/drawable/checkbox_iob_icon.xml | 8 +- .../main/res/drawable/checkbox_trend_icon.xml | 8 +- .../main/res/drawable/checkbox_tt_icon.xml | 0 .../main/res/drawable/ic_cp_basal_start.xml | 0 .../main/res/drawable/ic_loop_disabled.xml | 0 .../res/drawable/ic_loop_disconnected.xml | 0 .../src/main/res/drawable/ic_loop_lgs.xml | 0 .../src/main/res/drawable/ic_loop_open.xml | 0 .../src/main/res/drawable/ic_loop_paused.xml | 0 .../main/res/drawable/ic_loop_reconnect.xml | 0 .../src/main/res/drawable/ic_loop_resume.xml | 0 .../main/res/drawable/ic_target_activity.xml | 0 .../main/res/drawable/ic_target_cancel.xml | 0 .../res/drawable/ic_target_eatingsoon.xml | 0 .../src/main/res/drawable/ic_target_hypo.xml | 0 .../main/res/drawable/ic_target_manual.xml | 0 .../main/res/layout/dialog_profileswitch.xml | 6 +- ui/src/main/res/layout/dialog_temptarget.xml | 2 +- .../main/res/layout/treatments_fragment.xml | 4 +- ui/src/main/res/values/strings.xml | 14 ++ 138 files changed, 1246 insertions(+), 1034 deletions(-) create mode 100644 app-wear-shared/rx/src/main/java/info/nightscout/rx/events/EventSWUpdate.kt delete mode 100644 app/src/main/java/info/nightscout/androidaps/setupwizard/events/EventSWUpdate.kt rename app/src/test/java/info/nightscout/androidaps/plugins/{constraints => }/safety/SafetyPluginTest.kt (76%) rename core/core-main/src/main/res/drawable/{ic_actions_starttempbasal.xml => ic_actions_start_temp_basal.xml} (100%) rename {plugins => core/core-main}/src/main/res/drawable/ic_clone_48.xml (100%) rename {app => core/core-main}/src/main/res/drawable/ic_xdrip.xml (100%) rename {app/src/main/java/info/nightscout/androidaps => plugins/src/main/java/info/nightscout}/plugins/constraints/objectives/ObjectivesFragment.kt (96%) rename {app/src/main/java/info/nightscout/androidaps => plugins/src/main/java/info/nightscout}/plugins/constraints/objectives/ObjectivesPlugin.kt (84%) create mode 100644 plugins/src/main/java/info/nightscout/plugins/constraints/objectives/SntpClient.kt rename {app/src/main/java/info/nightscout/androidaps => plugins/src/main/java/info/nightscout}/plugins/constraints/objectives/activities/ObjectivesExamDialog.kt (88%) rename {app/src/main/java/info/nightscout/androidaps => plugins/src/main/java/info/nightscout}/plugins/constraints/objectives/dialogs/NtpProgressDialog.kt (98%) rename {app/src/main/java/info/nightscout/androidaps => plugins/src/main/java/info/nightscout}/plugins/constraints/objectives/events/EventObjectivesUpdateGui.kt (57%) rename {app/src/main/java/info/nightscout/androidaps => plugins/src/main/java/info/nightscout}/plugins/constraints/objectives/objectives/Objective.kt (98%) rename {app/src/main/java/info/nightscout/androidaps => plugins/src/main/java/info/nightscout}/plugins/constraints/objectives/objectives/Objective0.kt (96%) rename {app/src/main/java/info/nightscout/androidaps => plugins/src/main/java/info/nightscout}/plugins/constraints/objectives/objectives/Objective1.kt (92%) rename {app/src/main/java/info/nightscout/androidaps => plugins/src/main/java/info/nightscout}/plugins/constraints/objectives/objectives/Objective10.kt (73%) rename {app/src/main/java/info/nightscout/androidaps => plugins/src/main/java/info/nightscout}/plugins/constraints/objectives/objectives/Objective2.kt (98%) rename {app/src/main/java/info/nightscout/androidaps => plugins/src/main/java/info/nightscout}/plugins/constraints/objectives/objectives/Objective3.kt (91%) rename {app/src/main/java/info/nightscout/androidaps => plugins/src/main/java/info/nightscout}/plugins/constraints/objectives/objectives/Objective4.kt (67%) rename {app/src/main/java/info/nightscout/androidaps => plugins/src/main/java/info/nightscout}/plugins/constraints/objectives/objectives/Objective5.kt (81%) rename {app/src/main/java/info/nightscout/androidaps => plugins/src/main/java/info/nightscout}/plugins/constraints/objectives/objectives/Objective6.kt (80%) rename {app/src/main/java/info/nightscout/androidaps => plugins/src/main/java/info/nightscout}/plugins/constraints/objectives/objectives/Objective7.kt (74%) rename {app/src/main/java/info/nightscout/androidaps => plugins/src/main/java/info/nightscout}/plugins/constraints/objectives/objectives/Objective9.kt (73%) create mode 100644 plugins/src/main/java/info/nightscout/plugins/constraints/objectives/objectives/SntpClient.kt rename {app/src/main/java/info/nightscout/androidaps => plugins/src/main/java/info/nightscout}/plugins/constraints/safety/SafetyPlugin.kt (87%) create mode 100644 plugins/src/main/java/info/nightscout/plugins/di/ObjectivesModule.kt rename {app/src/main/java/info/nightscout/androidaps => plugins/src/main/java/info/nightscout/plugins}/di/SkinsModule.kt (71%) rename {app/src/main/java/info/nightscout/androidaps => plugins/src/main/java/info/nightscout}/plugins/general/actions/ActionsFragment.kt (86%) rename {app/src/main/java/info/nightscout/androidaps => plugins/src/main/java/info/nightscout}/plugins/general/actions/ActionsPlugin.kt (56%) rename {app/src/main/java/info/nightscout/androidaps => plugins/src/main/java/info/nightscout/plugins}/skins/SkinButtonsOn.kt (83%) rename {app/src/main/java/info/nightscout/androidaps => plugins/src/main/java/info/nightscout/plugins}/skins/SkinClassic.kt (82%) rename {app/src/main/java/info/nightscout/androidaps => plugins/src/main/java/info/nightscout/plugins}/skins/SkinInterface.kt (94%) rename {app/src/main/java/info/nightscout/androidaps => plugins/src/main/java/info/nightscout/plugins}/skins/SkinLargeDisplay.kt (81%) rename {app/src/main/java/info/nightscout/androidaps => plugins/src/main/java/info/nightscout/plugins}/skins/SkinListPreference.kt (95%) rename {app/src/main/java/info/nightscout/androidaps => plugins/src/main/java/info/nightscout/plugins}/skins/SkinLowRes.kt (88%) rename {app/src/main/java/info/nightscout/androidaps => plugins/src/main/java/info/nightscout/plugins}/skins/SkinProvider.kt (82%) rename {app/src/main/java/info/nightscout/androidaps/plugins/general/overview => plugins/src/main/java/info/nightscout/plugins/ui}/StatusLightHandler.kt (96%) rename app/src/main/res/drawable/ic_actions_cancelextbolus.xml => plugins/src/main/res/drawable/ic_actions_cancel_extended_bolus.xml (100%) rename {app => plugins}/src/main/res/drawable/ic_arrow_drop_down_white_24dp.xml (100%) rename app/src/main/res/drawable/ic_cancelbasal.xml => plugins/src/main/res/drawable/ic_cancel_basal.xml (100%) rename {app => plugins}/src/main/res/drawable/ic_cp_age_battery.xml (100%) rename {app => plugins}/src/main/res/drawable/ic_cp_age_cannula.xml (100%) rename {app => plugins}/src/main/res/drawable/ic_cp_age_insulin.xml (100%) rename {app => plugins}/src/main/res/drawable/ic_cp_age_sensor.xml (100%) rename {app => plugins}/src/main/res/drawable/ic_crosstarget.xml (100%) rename {app => plugins}/src/main/res/layout/actions_fragment.xml (95%) rename app/src/main/res/layout/careportal_stats_fragment.xml => plugins/src/main/res/layout/actions_stats_fragment.xml (93%) rename {app => plugins}/src/main/res/layout/objectives_exam_fragment.xml (95%) rename {app => plugins}/src/main/res/layout/objectives_fragment.xml (95%) rename {app => plugins}/src/main/res/layout/objectives_item.xml (100%) rename {app => plugins}/src/main/res/layout/overview_buttons_layout.xml (100%) rename {app => plugins}/src/main/res/layout/overview_fragment.xml (99%) rename {app => plugins}/src/main/res/layout/overview_graphs_layout.xml (100%) rename {app => plugins}/src/main/res/layout/overview_info_layout.xml (100%) rename {app => plugins}/src/main/res/layout/overview_statuslights_layout.xml (98%) create mode 100644 plugins/src/main/res/values/exam.xml create mode 100644 plugins/src/main/res/values/objectives.xml rename {app => plugins}/src/main/res/xml/pref_safety.xml (100%) create mode 100644 plugins/src/test/java/info/nightscout/androidaps/HardLimitsMock.kt rename {app/src/test/java/info/nightscout/androidaps => plugins/src/test/java/info/nightscout}/plugins/constraints/objectives/ObjectivesPluginTest.kt (79%) rename {app/src/test/java/info/nightscout/androidaps => plugins/src/test/java/info/nightscout}/plugins/source/GlimpPluginTest.kt (100%) rename {app/src/test/java/info/nightscout/androidaps => plugins/src/test/java/info/nightscout}/plugins/source/MM640GPluginTest.kt (100%) rename {app/src/test/java/info/nightscout/androidaps => plugins/src/test/java/info/nightscout}/plugins/source/NSClientPluginTest.kt (100%) rename {app/src/test/java/info/nightscout/androidaps => plugins/src/test/java/info/nightscout}/plugins/source/XdripPluginTest.kt (100%) rename {app => ui}/src/main/res/drawable/cb_background_bg.xml (97%) rename {app => ui}/src/main/res/drawable/cb_background_cob.xml (97%) rename {app => ui}/src/main/res/drawable/cb_background_iob.xml (97%) rename {app => ui}/src/main/res/drawable/cb_background_trend.xml (97%) rename {app => ui}/src/main/res/drawable/cb_background_tt.xml (100%) rename {app => ui}/src/main/res/drawable/checkbox_bg_icon.xml (97%) rename {app => ui}/src/main/res/drawable/checkbox_cob_icon.xml (97%) rename {app => ui}/src/main/res/drawable/checkbox_iob_icon.xml (97%) rename {app => ui}/src/main/res/drawable/checkbox_trend_icon.xml (97%) rename {app => ui}/src/main/res/drawable/checkbox_tt_icon.xml (100%) rename {app => ui}/src/main/res/drawable/ic_cp_basal_start.xml (100%) rename {app => ui}/src/main/res/drawable/ic_loop_disabled.xml (100%) rename {app => ui}/src/main/res/drawable/ic_loop_disconnected.xml (100%) rename {app => ui}/src/main/res/drawable/ic_loop_lgs.xml (100%) rename {app => ui}/src/main/res/drawable/ic_loop_open.xml (100%) rename {app => ui}/src/main/res/drawable/ic_loop_paused.xml (100%) rename {app => ui}/src/main/res/drawable/ic_loop_reconnect.xml (100%) rename {app => ui}/src/main/res/drawable/ic_loop_resume.xml (100%) rename {app => ui}/src/main/res/drawable/ic_target_activity.xml (100%) rename {app => ui}/src/main/res/drawable/ic_target_cancel.xml (100%) rename {app => ui}/src/main/res/drawable/ic_target_eatingsoon.xml (100%) rename {app => ui}/src/main/res/drawable/ic_target_hypo.xml (100%) rename {app => ui}/src/main/res/drawable/ic_target_manual.xml (100%) diff --git a/.idea/dictionaries/project_dictionary.xml b/.idea/dictionaries/project_dictionary.xml index 2e08ebd897..3989a176c5 100644 --- a/.idea/dictionaries/project_dictionary.xml +++ b/.idea/dictionaries/project_dictionary.xml @@ -8,6 +8,7 @@ actionstring aidex alarmack + alexpr allowednumbers androidaps autosens @@ -43,9 +44,14 @@ dexcom dexdrip diaconn + dlvoy + dttm + ecarbs enteredby enteredinsulin + eoflow eopatch + epss eveningoutpost eversense extendedbolus @@ -56,12 +62,15 @@ gson hmac iage + infinivocgm insulet + intelligo iobtotal joda libre listdelimiter localprofile + lyumjev mdtp medtronic mgdl @@ -74,6 +83,7 @@ nightscout notif nsclient + oaps okcancel omnipod openaps @@ -88,10 +98,12 @@ profileswitch pumpbtcomm pumpcontrol + pumpdrivers quickwizard readstatus realduration refresheventsfromnightscout + rfspy rileylink roboelectric rozman @@ -104,6 +116,8 @@ soundid splitted ssid + statuslight + statuslights superbolus targethigh targetlow @@ -119,6 +133,7 @@ totp tunedays uart + unfinshed urgentalarm wizzardpage xdrip diff --git a/app-wear-shared/rx/src/main/java/info/nightscout/rx/events/EventSWUpdate.kt b/app-wear-shared/rx/src/main/java/info/nightscout/rx/events/EventSWUpdate.kt new file mode 100644 index 0000000000..6ea5119760 --- /dev/null +++ b/app-wear-shared/rx/src/main/java/info/nightscout/rx/events/EventSWUpdate.kt @@ -0,0 +1,3 @@ +package info.nightscout.rx.events + +class EventSWUpdate(var redraw: Boolean) : Event() \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 49cdffb837..d2c714bfee 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -222,9 +222,6 @@ dependencies { // MainApp api "com.uber.rxdogtag2:rxdogtag:2.0.1" - // Overview - api 'com.google.android.flexbox:flexbox:3.0.0' - // APS api 'org.mozilla:rhino:1.7.14' diff --git a/app/src/main/java/info/nightscout/androidaps/activities/MyPreferenceFragment.kt b/app/src/main/java/info/nightscout/androidaps/activities/MyPreferenceFragment.kt index f7dadf3667..d61f7bce1a 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/MyPreferenceFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/MyPreferenceFragment.kt @@ -30,7 +30,7 @@ import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin import info.nightscout.androidaps.plugins.aps.openAPSSMBDynamicISF.OpenAPSSMBDynamicISFPlugin import info.nightscout.androidaps.plugins.configBuilder.PluginStore -import info.nightscout.androidaps.plugins.constraints.safety.SafetyPlugin +import info.nightscout.plugins.constraints.safety.SafetyPlugin import info.nightscout.androidaps.plugins.general.maintenance.MaintenancePlugin import info.nightscout.androidaps.plugins.general.wear.WearPlugin import info.nightscout.androidaps.plugins.pump.combo.ComboPlugin diff --git a/app/src/main/java/info/nightscout/androidaps/di/AppComponent.kt b/app/src/main/java/info/nightscout/androidaps/di/AppComponent.kt index 0d598198f5..6ec767919d 100644 --- a/app/src/main/java/info/nightscout/androidaps/di/AppComponent.kt +++ b/app/src/main/java/info/nightscout/androidaps/di/AppComponent.kt @@ -25,6 +25,7 @@ import info.nightscout.automation.di.AutomationModule import info.nightscout.database.impl.DatabaseModule import info.nightscout.implementation.di.ImplementationModule import info.nightscout.plugins.di.PluginsModule +import info.nightscout.plugins.di.SkinsModule import info.nightscout.rx.di.RxModule import info.nightscout.shared.di.SharedModule import info.nightscout.ui.di.UiModule @@ -36,12 +37,10 @@ import javax.inject.Singleton AndroidInjectionModule::class, AppModule::class, PluginsListModule::class, - SkinsModule::class, ActivitiesModule::class, FragmentsModule::class, ReceiversModule::class, ServicesModule::class, - ObjectivesModule::class, WizardModule::class, APSModule::class, WorkflowModule::class, diff --git a/app/src/main/java/info/nightscout/androidaps/di/FragmentsModule.kt b/app/src/main/java/info/nightscout/androidaps/di/FragmentsModule.kt index 818a8f4398..93c61aa5ff 100644 --- a/app/src/main/java/info/nightscout/androidaps/di/FragmentsModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/di/FragmentsModule.kt @@ -3,13 +3,13 @@ package info.nightscout.androidaps.di import dagger.Module import dagger.android.ContributesAndroidInjector import info.nightscout.androidaps.activities.MyPreferenceFragment -import info.nightscout.androidaps.plugins.constraints.objectives.dialogs.NtpProgressDialog +import info.nightscout.plugins.constraints.objectives.dialogs.NtpProgressDialog import info.nightscout.androidaps.plugins.aps.OpenAPSFragment import info.nightscout.androidaps.plugins.aps.loop.LoopFragment import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderFragment -import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesFragment -import info.nightscout.androidaps.plugins.constraints.objectives.activities.ObjectivesExamDialog -import info.nightscout.androidaps.plugins.general.actions.ActionsFragment +import info.nightscout.plugins.constraints.objectives.ObjectivesFragment +import info.nightscout.plugins.constraints.objectives.activities.ObjectivesExamDialog +import info.nightscout.plugins.general.actions.ActionsFragment import info.nightscout.androidaps.plugins.general.maintenance.MaintenanceFragment import info.nightscout.androidaps.plugins.general.overview.OverviewFragment import info.nightscout.androidaps.plugins.general.overview.dialogs.EditQuickWizardDialog diff --git a/app/src/main/java/info/nightscout/androidaps/di/ObjectivesModule.kt b/app/src/main/java/info/nightscout/androidaps/di/ObjectivesModule.kt index b10655655e..200b83579f 100644 --- a/app/src/main/java/info/nightscout/androidaps/di/ObjectivesModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/di/ObjectivesModule.kt @@ -1,23 +1,2 @@ package info.nightscout.androidaps.di -import dagger.Module -import dagger.android.ContributesAndroidInjector -import info.nightscout.androidaps.plugins.constraints.objectives.objectives.* - -@Module -@Suppress("unused") -abstract class ObjectivesModule { - - @ContributesAndroidInjector abstract fun objectiveInjector(): Objective - @ContributesAndroidInjector abstract fun objective0Injector(): Objective0 - @ContributesAndroidInjector abstract fun objective1Injector(): Objective1 - @ContributesAndroidInjector abstract fun objective2Injector(): Objective2 - @ContributesAndroidInjector abstract fun objective3Injector(): Objective3 - @ContributesAndroidInjector abstract fun objective4Injector(): Objective4 - @ContributesAndroidInjector abstract fun objective5Injector(): Objective5 - @ContributesAndroidInjector abstract fun objective6Injector(): Objective6 - @ContributesAndroidInjector abstract fun objective7Injector(): Objective7 - @ContributesAndroidInjector abstract fun objective9Injector(): Objective9 - @ContributesAndroidInjector abstract fun objective10Injector(): Objective10 - -} \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/di/PluginsListModule.kt b/app/src/main/java/info/nightscout/androidaps/di/PluginsListModule.kt index 51e76c035e..1353f1d40b 100644 --- a/app/src/main/java/info/nightscout/androidaps/di/PluginsListModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/di/PluginsListModule.kt @@ -15,9 +15,9 @@ import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin import info.nightscout.androidaps.plugins.aps.openAPSSMBDynamicISF.OpenAPSSMBDynamicISFPlugin import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin -import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesPlugin -import info.nightscout.androidaps.plugins.constraints.safety.SafetyPlugin -import info.nightscout.androidaps.plugins.general.actions.ActionsPlugin +import info.nightscout.plugins.constraints.objectives.ObjectivesPlugin +import info.nightscout.plugins.constraints.safety.SafetyPlugin +import info.nightscout.plugins.general.actions.ActionsPlugin import info.nightscout.androidaps.plugins.general.dataBroadcaster.DataBroadcastPlugin import info.nightscout.androidaps.plugins.general.maintenance.MaintenancePlugin import info.nightscout.androidaps.plugins.general.overview.OverviewPlugin diff --git a/app/src/main/java/info/nightscout/androidaps/di/UIModule.kt b/app/src/main/java/info/nightscout/androidaps/di/UIModule.kt index 6ed59b4f58..457222578e 100644 --- a/app/src/main/java/info/nightscout/androidaps/di/UIModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/di/UIModule.kt @@ -3,7 +3,7 @@ package info.nightscout.androidaps.di import dagger.Module import dagger.android.ContributesAndroidInjector import info.nightscout.ui.widget.WidgetConfigureActivity -import info.nightscout.androidaps.skins.SkinListPreference +import info.nightscout.plugins.skins.SkinListPreference import info.nightscout.ui.widget.Widget @Module diff --git a/app/src/main/java/info/nightscout/androidaps/implementations/ActivityNamesImpl.kt b/app/src/main/java/info/nightscout/androidaps/implementations/ActivityNamesImpl.kt index 61c6f60803..548d4353b1 100644 --- a/app/src/main/java/info/nightscout/androidaps/implementations/ActivityNamesImpl.kt +++ b/app/src/main/java/info/nightscout/androidaps/implementations/ActivityNamesImpl.kt @@ -6,14 +6,20 @@ import android.os.Bundle import androidx.annotation.RawRes import androidx.fragment.app.FragmentManager import info.nightscout.androidaps.MainActivity +import info.nightscout.androidaps.activities.HistoryBrowseActivity import info.nightscout.androidaps.activities.SingleFragmentActivity import info.nightscout.androidaps.services.AlarmSoundService import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.ui.activities.BolusProgressHelperActivity import info.nightscout.ui.activities.ErrorHelperActivity import info.nightscout.ui.activities.TDDStatsActivity +import info.nightscout.ui.dialogs.CareDialog +import info.nightscout.ui.dialogs.ExtendedBolusDialog +import info.nightscout.ui.dialogs.FillDialog import info.nightscout.ui.dialogs.ProfileSwitchDialog import info.nightscout.ui.dialogs.ProfileViewerDialog +import info.nightscout.ui.dialogs.TempBasalDialog +import info.nightscout.ui.dialogs.TempTargetDialog import info.nightscout.ui.dialogs.WizardDialog import javax.inject.Inject @@ -21,6 +27,7 @@ class ActivityNamesImpl @Inject constructor() : ActivityNames { override val mainActivityClass: Class<*> = MainActivity::class.java override val tddStatsActivity: Class<*> = TDDStatsActivity::class.java + override val historyBrowseActivity: Class<*> = HistoryBrowseActivity::class.java override val errorHelperActivity: Class<*> = ErrorHelperActivity::class.java override val bolusProgressHelperActivity: Class<*> = BolusProgressHelperActivity::class.java override val singleFragmentActivity: Class<*> = SingleFragmentActivity::class.java @@ -50,6 +57,26 @@ class ActivityNamesImpl @Inject constructor() : ActivityNames { .show(fragmentManager, "ProfileSwitchDialog") } + override fun runTempBasalDialog(fragmentManager: FragmentManager) { + TempBasalDialog() + .show(fragmentManager, "TempBasalDialog") + } + + override fun runTempTargetDialog(fragmentManager: FragmentManager) { + TempTargetDialog() + .show(fragmentManager, "TempTargetDialog") + } + + override fun runExtendedBolusDialog(fragmentManager: FragmentManager) { + ExtendedBolusDialog() + .show(fragmentManager, "ExtendedBolusDialog") + } + + override fun runFillDialog(fragmentManager: FragmentManager) { + FillDialog() + .show(fragmentManager, "FillDialog") + } + override fun runProfileViewerDialog(fragmentManager: FragmentManager, time: Long, mode: ActivityNames.Mode, customProfile: String?, customProfileName: String?, customProfile2: String?) { ProfileViewerDialog() .also { @@ -61,6 +88,17 @@ class ActivityNamesImpl @Inject constructor() : ActivityNames { bundle.putString("customProfile2", customProfile2) } } - .show(fragmentManager, "ProfileSwitchDialog") + .show(fragmentManager, "ProfileViewer") + } + + override fun runCareDialog(fragmentManager: FragmentManager, options: ActivityNames.EventType, event: Int) { + CareDialog() + .also { + it.arguments = Bundle().also { bundle -> + bundle.putInt("event", event) + bundle.putInt("options", options.ordinal) + } + } + .show(fragmentManager, "CareDialog") } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/OpenAPSAMAPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/OpenAPSAMAPlugin.kt index b880fa7f5b..ad2942c350 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/OpenAPSAMAPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/OpenAPSAMAPlugin.kt @@ -33,6 +33,7 @@ import info.nightscout.rx.bus.RxBus import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.LTag import info.nightscout.shared.interfaces.ResourceHelper +import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.utils.DateUtil import org.json.JSONException import javax.inject.Inject @@ -55,7 +56,8 @@ class OpenAPSAMAPlugin @Inject constructor( private val fabricPrivacy: FabricPrivacy, private val dateUtil: DateUtil, private val repository: AppRepository, - private val glucoseStatusProvider: GlucoseStatusProvider + private val glucoseStatusProvider: GlucoseStatusProvider, + private val sp: SP ) : PluginBase( PluginDescription() .mainType(PluginType.APS) @@ -66,7 +68,7 @@ class OpenAPSAMAPlugin @Inject constructor( .preferencesId(R.xml.pref_openapsama) .description(R.string.description_ama), aapsLogger, rh, injector -), APS { +), APS, Constraints { // last values override var lastAPSRun: Long = 0 @@ -207,4 +209,13 @@ class OpenAPSAMAPlugin @Inject constructor( //deviceStatus.suggested = determineBasalResultAMA.json; } + + override fun applyMaxIOBConstraints(maxIob: Constraint): Constraint { + if (isEnabled()) { + val maxIobPref: Double = sp.getDouble(R.string.key_openapsma_max_iob, 1.5) + maxIob.setIfSmaller(aapsLogger, maxIobPref, rh.gs(R.string.limitingiob, maxIobPref, rh.gs(R.string.maxvalueinpreferences)), this) + maxIob.setIfSmaller(aapsLogger, hardLimits.maxIobAMA(), rh.gs(R.string.limitingiob, hardLimits.maxIobAMA(), rh.gs(R.string.hardlimit)), this) + } + return maxIob + } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/OpenAPSSMBPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/OpenAPSSMBPlugin.kt index 483f22b3b2..19149c80e3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/OpenAPSSMBPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/OpenAPSSMBPlugin.kt @@ -240,5 +240,14 @@ class OpenAPSSMBPlugin @Inject constructor( return value } + override fun applyMaxIOBConstraints(maxIob: Constraint): Constraint { + if (isEnabled()) { + val maxIobPref: Double = sp.getDouble(R.string.key_openapssmb_max_iob, 3.0) + maxIob.setIfSmaller(aapsLogger, maxIobPref, rh.gs(R.string.limitingiob, maxIobPref, rh.gs(R.string.maxvalueinpreferences)), this) + maxIob.setIfSmaller(aapsLogger, hardLimits.maxIobSMB(), rh.gs(R.string.limitingiob, hardLimits.maxIobSMB(), rh.gs(R.string.hardlimit)), this) + } + return maxIob + } + fun provideDetermineBasalAdapter(): DetermineBasalAdapterInterface = DetermineBasalAdapterSMBJS(ScriptReader(context), injector) } \ No newline at end of file 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 12a2e2fcdc..146e972f10 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 @@ -29,7 +29,7 @@ import dagger.android.HasAndroidInjector import dagger.android.support.DaggerFragment import info.nightscout.androidaps.R import info.nightscout.androidaps.data.ProfileSealed -import info.nightscout.androidaps.databinding.OverviewFragmentBinding +import info.nightscout.plugins.databinding.OverviewFragmentBinding import info.nightscout.androidaps.events.EventEffectiveProfileSwitchChanged import info.nightscout.androidaps.events.EventNewBG import info.nightscout.androidaps.events.EventPreferenceChange @@ -54,7 +54,7 @@ import info.nightscout.androidaps.plugins.general.overview.events.EventUpdateOve import info.nightscout.androidaps.plugins.general.overview.graphData.GraphData import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider import info.nightscout.androidaps.plugins.pump.omnipod.eros.OmnipodErosPumpPlugin -import info.nightscout.androidaps.skins.SkinProvider +import info.nightscout.plugins.skins.SkinProvider import info.nightscout.androidaps.utils.DefaultValueHelper import info.nightscout.androidaps.utils.ToastUtils import info.nightscout.androidaps.utils.alertDialogs.OKDialog @@ -88,6 +88,7 @@ import info.nightscout.plugins.source.DexcomPlugin import info.nightscout.plugins.source.XdripPlugin import info.nightscout.plugins.sync.nsclient.data.NSSettingsStatus import info.nightscout.plugins.sync.nsclient.data.ProcessedDeviceStatusData +import info.nightscout.plugins.ui.StatusLightHandler import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.bus.RxBus import info.nightscout.rx.events.EventAcceptOpenLoopChange diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/DataHandlerMobile.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/DataHandlerMobile.kt index 985178bb1a..d5e84301ba 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/DataHandlerMobile.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/DataHandlerMobile.kt @@ -995,7 +995,7 @@ class DataHandlerMobile @Inject constructor( ret += if (!result.isChangeRequested) { rh.gs(R.string.nochangerequested) + "\n" } else if (result.rate == 0.0 && result.duration == 0) { - rh.gs(R.string.canceltemp) + "\n" + rh.gs(R.string.cancel_temp) + "\n" } else { rh.gs(R.string.rate) + ": " + DecimalFormatter.to2Decimal(result.rate) + " U/h " + "(" + DecimalFormatter.to2Decimal(result.rate / activePlugin.activePump.baseBasalRate * 100) + "%)\n" + diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityOref1Plugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityOref1Plugin.kt index 328e89013a..b7c036d891 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityOref1Plugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/sensitivity/SensitivityOref1Plugin.kt @@ -4,6 +4,7 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R import info.nightscout.androidaps.annotations.OpenForTesting import info.nightscout.androidaps.extensions.isPSEvent5minBack +import info.nightscout.androidaps.interfaces.Constraints import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.interfaces.Sensitivity.SensitivityType import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensDataStore @@ -13,6 +14,7 @@ import info.nightscout.database.entities.TherapyEvent import info.nightscout.database.impl.AppRepository import info.nightscout.interfaces.Constants import info.nightscout.interfaces.aps.SMBDefaults +import info.nightscout.interfaces.constraints.Constraint import info.nightscout.interfaces.plugin.PluginDescription import info.nightscout.interfaces.plugin.PluginType import info.nightscout.interfaces.profile.Profile @@ -51,7 +53,7 @@ class SensitivityOref1Plugin @Inject constructor( .description(R.string.description_sensitivity_oref1) .setDefault(), injector, aapsLogger, rh, sp -) { +), Constraints { override fun detectSensitivity(ads: AutosensDataStore, fromTime: Long, toTime: Long): AutosensResult { val profile = profileFunction.getProfile() @@ -235,4 +237,9 @@ class SensitivityOref1Plugin @Inject constructor( override val id: SensitivityType get() = SensitivityType.SENSITIVITY_OREF1 + + override fun isUAMEnabled(value: Constraint): Constraint { + if (!isEnabled()) value.set(aapsLogger, false, rh.gs(info.nightscout.plugins.R.string.uamdisabledoref1notselected), this) + return value + } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt b/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt index ded3471ea3..c5f016e3f2 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt @@ -14,8 +14,8 @@ import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.interfaces.CommandQueue import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin -import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesFragment -import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesPlugin +import info.nightscout.plugins.constraints.objectives.ObjectivesFragment +import info.nightscout.plugins.constraints.objectives.ObjectivesPlugin import info.nightscout.androidaps.plugins.pump.common.events.EventRileyLinkDeviceStatusChange import info.nightscout.androidaps.plugins.pump.omnipod.dash.OmnipodDashPumpPlugin import info.nightscout.androidaps.plugins.pump.omnipod.eros.OmnipodErosPumpPlugin @@ -32,7 +32,7 @@ import info.nightscout.androidaps.setupwizard.elements.SWInfoText import info.nightscout.androidaps.setupwizard.elements.SWPlugin import info.nightscout.androidaps.setupwizard.elements.SWPreference import info.nightscout.androidaps.setupwizard.elements.SWRadioButton -import info.nightscout.androidaps.setupwizard.events.EventSWUpdate +import info.nightscout.rx.events.EventSWUpdate import info.nightscout.androidaps.utils.CryptoUtil import info.nightscout.androidaps.utils.extensions.isRunningTest import info.nightscout.interfaces.AndroidPermission diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.kt b/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.kt index 8e6f5882bf..d73e0f5388 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.kt @@ -13,7 +13,7 @@ import info.nightscout.androidaps.events.EventPumpStatusChanged import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.plugins.pump.common.events.EventRileyLinkDeviceStatusChange import info.nightscout.androidaps.setupwizard.elements.SWItem -import info.nightscout.androidaps.setupwizard.events.EventSWUpdate +import info.nightscout.rx.events.EventSWUpdate import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.core.fabric.FabricPrivacy import info.nightscout.interfaces.locale.LocaleHelper.update diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWItem.kt b/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWItem.kt index 1dcff122c5..3a28b38235 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWItem.kt +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWItem.kt @@ -9,7 +9,7 @@ import androidx.appcompat.app.AppCompatActivity import dagger.android.HasAndroidInjector import info.nightscout.androidaps.events.EventPreferenceChange import info.nightscout.shared.interfaces.ResourceHelper -import info.nightscout.androidaps.setupwizard.events.EventSWUpdate +import info.nightscout.rx.events.EventSWUpdate import info.nightscout.androidaps.utils.protection.PasswordCheck import info.nightscout.rx.bus.RxBus import info.nightscout.rx.logging.AAPSLogger diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWPlugin.kt b/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWPlugin.kt index abcfa73e3c..6faeae5233 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWPlugin.kt @@ -12,7 +12,7 @@ import info.nightscout.androidaps.activities.MyPreferenceFragment import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin import info.nightscout.androidaps.plugins.configBuilder.PluginStore import info.nightscout.androidaps.setupwizard.SWDefinition -import info.nightscout.androidaps.setupwizard.events.EventSWUpdate +import info.nightscout.rx.events.EventSWUpdate import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginType import info.nightscout.rx.events.EventConfigBuilderChange diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/events/EventSWUpdate.kt b/app/src/main/java/info/nightscout/androidaps/setupwizard/events/EventSWUpdate.kt deleted file mode 100644 index f67b6b0566..0000000000 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/events/EventSWUpdate.kt +++ /dev/null @@ -1,5 +0,0 @@ -package info.nightscout.androidaps.setupwizard.events - -import info.nightscout.rx.events.Event - -class EventSWUpdate(var redraw: Boolean) : Event() \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/utils/SntpClient.kt b/app/src/main/java/info/nightscout/androidaps/utils/SntpClient.kt index 475507b645..6f01aa6a78 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/SntpClient.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/SntpClient.kt @@ -1,14 +1,5 @@ package info.nightscout.androidaps.utils -import android.os.SystemClock -import info.nightscout.rx.logging.AAPSLogger -import info.nightscout.shared.utils.DateUtil -import java.net.DatagramPacket -import java.net.DatagramSocket -import java.net.InetAddress -import javax.inject.Inject -import javax.inject.Singleton - /* * Copyright (C) 2008 The Android Open Source Project * @@ -23,192 +14,4 @@ import javax.inject.Singleton * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ /** - * {@hide} - * - * - * Simple SNTP client class for retrieving network time. - * - * - * Sample usage: - *
SntpClient client = new SntpClient();
- * if (client.requestTime("time.foo.com")) {
- * long now = client.getNtpTime() + SystemClock.elapsedRealtime() - client.getNtpTimeReference();
- * }
-
* - */ -@Singleton -class SntpClient @Inject constructor( - private val aapsLogger: AAPSLogger, - private val dateUtil: DateUtil -) { - - companion object { - //private final int REFERENCE_TIME_OFFSET = 16; - private const val ORIGINATE_TIME_OFFSET = 24 - private const val RECEIVE_TIME_OFFSET = 32 - private const val TRANSMIT_TIME_OFFSET = 40 - private const val NTP_PACKET_SIZE = 48 - private const val NTP_PORT = 123 - private const val NTP_MODE_CLIENT = 3 - private const val NTP_VERSION = 3 - - // Number of seconds between Jan 1, 1900 and Jan 1, 1970 - // 70 years plus 17 leap days - private const val OFFSET_1900_TO_1970 = (365L * 70L + 17L) * 24L * 60L * 60L - } - - /** - * Returns the time computed from the NTP transaction. - * - * @return time value computed from NTP server response. - */ - // system time computed from NTP server response - private var ntpTime: Long = 0 - - /** - * Returns the reference clock value (value of SystemClock.elapsedRealtime()) - * corresponding to the NTP time. - * - * @return reference clock corresponding to the NTP time. - */ - // value of SystemClock.elapsedRealtime() corresponding to mNtpTime - private var ntpTimeReference: Long = 0 - - /** - * Returns the round trip time of the NTP transaction - * - * @return round trip time in milliseconds. - */ - // round trip time in milliseconds - private var roundTripTime: Long = 0 - - abstract class Callback : Runnable { - - var networkConnected = false - var success = false - var time: Long = 0 - } - - @Synchronized fun ntpTime(callback: Callback, isConnected: Boolean) { - callback.networkConnected = isConnected - if (callback.networkConnected) { - Thread { doNtpTime(callback) }.start() - } else { - callback.run() - } - } - - fun doNtpTime(callback: Callback) { - aapsLogger.debug("Time detection started") - callback.success = requestTime("time.google.com", 5000) - callback.time = ntpTime + SystemClock.elapsedRealtime() - ntpTimeReference - aapsLogger.debug("Time detection ended: " + callback.success + " " + dateUtil.dateAndTimeString(ntpTime)) - callback.run() - } - - /** - * Sends an SNTP request to the given host and processes the response. - * - * @param host host name of the server. - * @param timeout network timeout in milliseconds. - * @return true if the transaction was successful. - */ - @Suppress("SameParameterValue") - @Synchronized private fun requestTime(host: String, timeout: Int): Boolean { - try { - val socket = DatagramSocket() - socket.soTimeout = timeout - val address = InetAddress.getByName(host) - val buffer = ByteArray(NTP_PACKET_SIZE) - val request = DatagramPacket(buffer, buffer.size, address, NTP_PORT) - - // set mode = 3 (client) and version = 3 - // mode is in low 3 bits of first byte - // version is in bits 3-5 of first byte - buffer[0] = (NTP_MODE_CLIENT or (NTP_VERSION shl 3)).toByte() - - // get current time and write it to the request packet - val requestTime = System.currentTimeMillis() - val requestTicks = SystemClock.elapsedRealtime() - writeTimeStamp(buffer, TRANSMIT_TIME_OFFSET, requestTime) - socket.send(request) - - // read the response - val response = DatagramPacket(buffer, buffer.size) - socket.receive(response) - val responseTicks = SystemClock.elapsedRealtime() - val responseTime = requestTime + (responseTicks - requestTicks) - socket.close() - - // extract the results - val originateTime = readTimeStamp(buffer, ORIGINATE_TIME_OFFSET) - val receiveTime = readTimeStamp(buffer, RECEIVE_TIME_OFFSET) - val transmitTime = readTimeStamp(buffer, TRANSMIT_TIME_OFFSET) - val roundTripTime = responseTicks - requestTicks - (transmitTime - receiveTime) - val clockOffset = (receiveTime - originateTime + (transmitTime - responseTime)) / 2 - - // save our results - use the times on this side of the network latency - // (response rather than request time) - ntpTime = responseTime + clockOffset - ntpTimeReference = responseTicks - this.roundTripTime = roundTripTime - } catch (e: Exception) { - aapsLogger.debug("request time failed: $e") - return false - } - return true - } - - /** - * Reads an unsigned 32 bit big endian number from the given offset in the buffer. - */ - private fun read32(buffer: ByteArray, offset: Int): Long { - val b0 = buffer[offset] - val b1 = buffer[offset + 1] - val b2 = buffer[offset + 2] - val b3 = buffer[offset + 3] - - // convert signed bytes to unsigned values - val i0 = if (b0.toInt() and 0x80 == 0x80) (b0.toInt() and 0x7F) + 0x80 else b0.toInt() - val i1 = if (b1.toInt() and 0x80 == 0x80) (b1.toInt() and 0x7F) + 0x80 else b1.toInt() - val i2 = if (b2.toInt() and 0x80 == 0x80) (b2.toInt() and 0x7F) + 0x80 else b2.toInt() - val i3 = if (b3.toInt() and 0x80 == 0x80) (b3.toInt() and 0x7F) + 0x80 else b3.toInt() - return (i0.toLong() shl 24) + (i1.toLong() shl 16) + (i2.toLong() shl 8) + i3.toLong() - } - - /** - * Reads the NTP time stamp at the given offset in the buffer and returns - * it as a system time (milliseconds since January 1, 1970). - */ - private fun readTimeStamp(buffer: ByteArray, offset: Int): Long { - val seconds = read32(buffer, offset) - val fraction = read32(buffer, offset + 4) - return (seconds - OFFSET_1900_TO_1970) * 1000 + fraction * 1000L / 0x100000000L - } - - /** - * Writes system time (milliseconds since January 1, 1970) as an NTP time stamp - * at the given offset in the buffer. - */ - @Suppress("SameParameterValue") - private fun writeTimeStamp(buffer: ByteArray, offsetParam: Int, time: Long) { - var offset = offsetParam - var seconds = time / 1000L - val milliseconds = time - seconds * 1000L - seconds += OFFSET_1900_TO_1970 - - // write seconds in big endian format - buffer[offset++] = (seconds shr 24).toByte() - buffer[offset++] = (seconds shr 16).toByte() - buffer[offset++] = (seconds shr 8).toByte() - buffer[offset++] = (seconds shr 0).toByte() - val fraction = milliseconds * 0x100000000L / 1000L - // write fraction in big endian format - buffer[offset++] = (fraction shr 24).toByte() - buffer[offset++] = (fraction shr 16).toByte() - buffer[offset++] = (fraction shr 8).toByte() - // low order bits should be random data - buffer[offset] = (Math.random() * 255.0).toInt().toByte() - } -} \ No newline at end of file + */ \ No newline at end of file diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml index df1e452145..50034823ac 100644 --- a/app/src/main/res/menu/menu_main.xml +++ b/app/src/main/res/menu/menu_main.xml @@ -22,7 +22,7 @@ android:id="@+id/nav_historybrowser" android:orderInCategory="1" app:showAsAction="never" - android:title="@string/nav_historybrowser" /> + android:title="@string/nav_history_browser" /> zh - - @string/child - @string/teenage - @string/adult - @string/resistantadult - @string/pregnant - - - @string/key_child - @string/key_teenage - @string/key_adult - @string/key_resistantadult - @string/key_pregnant - - 15 30 diff --git a/app/src/main/res/values/exam.xml b/app/src/main/res/values/exam.xml index 6ef4c697a6..045e125f3d 100644 --- a/app/src/main/res/values/exam.xml +++ b/app/src/main/res/values/exam.xml @@ -1,230 +1,3 @@ - What is true about DIA? - Duration of Insulin Action (DIA) - You should set the value for DIA in your profile. - The minimum allowed value is 5 hours. - https://androidaps.readthedocs.io/en/latest/EN/Configuration/Config-Builder.html?#insulin - If you are satisfied that the value for DIA that you used in your pump prior to AAPS worked well, there is no need to change this when you start looping. - You should determine for yourself the appropriate value for DIA. - Hypo Temp-Target - What is primary reason to set a hypo temp target? - To correct for hypos caused by incorrect basal rate settings. - To prevent AAPS from overcorrecting for a blood glucose rise caused by the fast acting carbs used to treat a hypo. - To correct for a hypo induced as a result of exercise. - To prevent blood glucose from going low if there is already a 0% temporary basal rate running. - https://androidaps.readthedocs.io/en/latest/EN/Usage/temptarget.html - Which profile can be used and configured offline? - Topic: Offline Profile - NS Profile can be used, but not configured. - https://androidaps.readthedocs.io/en/latest/EN/Configuration/Config-Builder.html#profile - Reasons for applying "Disconnect pump" in AAPS - What should be done when disconnecting the pump? - This is unnecessary as insulin will not be delivered if the pump is physically disconnected. - It prevents AAPS from accounting for insulin that was not delivered whilst the pump is physically disconnected.  - It will not stop insulin delivery if the pump remains connected. - It will send AAPS into open loop mode. - https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/FAQ.html#other-settings - AAPS Settings - AAPS Settings - What are the best practices for backing up your settings? - You do not need to export your settings provided that you make a note of them. - Export your settings after you finish completing an objective. - Export your settings after changing any of your settings. - Export your settings after you finish your initial set-up and have set your Preferences. - Export your settings locally using the maintenance menu. - Your settings file is found in the folder Internal Storage/AAPS/preferences on your phone. - Copy your preferences file to a safe location outside of your phone (e.g. by using a cloud drive, connecting a cable to a computer, email, etc.) - If your phone is damaged or lost, there are easy ways to remotely recover your settings without a backup. - https://androidaps.readthedocs.io/en/latest/EN/Usage/ExportImportSettings.html - https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/FAQ.html#what-emergency-equipment-is-recommended-to-take-with-me - Noisy CGM Readings - What should be done if CGM data is noisy? - Do nothing - AAPS will deal with it. - Disable the closed loop to avoid possible over or underdosing. - Replace consistently noisy or inaccurate sensors. - Verify that your CGM app provides smoothed data. - https://androidaps.readthedocs.io/en/latest/EN/Usage/Smoothing-Blood-Glucose-Data-in-xDrip.html#smoothing-blood-glucose-data - Exercise and Profiles - How can you use profiles to best help the system deal with aerobic exercise? - Do a profile switch to less than 100%. - Do a profile switch to more than 100%. - Leave the profile set to 100%. - Suspend the loop. - https://androidaps.readthedocs.io/en/latest/EN/Usage/temptarget.html#activity-temp-target - Exercise and Temporary Targets - How can you use temporary targets to best help the system deal with aerobic exercise? - Set an activity blood glucose target starting a suitable time before beginning exercise. - Set an activity blood glucose target after finishing exercise. - Leave your blood glucose target unchanged. - Wait until blood glucose drops below your hypo temp target and then eat 15 g of fast acting carbohydrates. - https://androidaps.readthedocs.io/en/latest/EN/Usage/temptarget.html#activity-temp-target - Disabled/Suspended loop - Do I receive insulin when the loop is disabled/suspended? - Yes, basal insulin continues to be delivered. - No, delivery of insulin is stopped. - Basal, ISF, and I:C Testing - When should these values be validated? - Before starting looping. - When experiencing frequent high or low blood glucose. - At least once per week. - Once set and validated, these values should not change over time. - https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/FAQ.html#androidaps-settings - Prerequisites - What is essential to set up and use AAPS? - Validated profile information (Basal, IC, ISF, DIA). - A computer with Android Studio installed and configured. - A supported phone. - A compatible insulin pump if you are planning to run a closed loop. - Nightscout, to keep a log of all data and review settings. - A Tidepool account. - A Google account. - A Github account. - Experience in programming or editing code. - A MiniMed 670G pump. - https://androidaps.readthedocs.io/en/latest/EN/Module/module.html - A Smartwatch. - A Supported CGM. - Prerequisites - What is essential to set up and use AAPS? - Validated information to set up a profile (ISF, I:C ratio, basal rates, DIA etc.). - A compatible Android device (e.g. mobile/cell phone, full Android watch, or tablet). - AAPS requires an internet connection in order to run in closed loop. - A supported CGM and appropriate app to receive blood glucose values on the phone/device. - https://androidaps.readthedocs.io/en/latest/EN/Module/module.html - Updating AAPS - Check all correct answers. - You need to have Git installed and configured on your computer. - When updated versions of AAPS are released, the earlier versions may be remotely limited after a specified time. - You should save and note the location of your keystore and use the same signing key for updates as for your previous installation. - Never update if the system is working well. - If you have difficulty building the apk, you can install an apk that has been built by a friend. - https://androidaps.readthedocs.io/en/latest/EN/Installing-AndroidAPS/Update-to-new-version.html#update-to-a-new-version-or-branch - Troubleshooting - Where can you look for help with AAPS? - You can ask for advice in the AAPS Users Facebook group. - You should read (and re-read) the AAPS documentation. - You can ask for advice and log technical problems or issues in the AAPS Discord. - You should ask your diabetes clinic/endocrinologist. - https://androidaps.readthedocs.io/en/latest/EN/Installing-AndroidAPS/Update-to-new-version.html#troubleshooting - https://www.facebook.com/groups/AndroidAPSUsers/ - https://discord.gg/4fQUWHZ4Mw - Insulin Plugins - Which insulin should you use with the Ultra-Rapid Oref plugin? - Fiasp® - NovoRapid®/Novolog® - Humalog® - Actrapid®/Humalin R®/"regular" human insulin. - https://androidaps.readthedocs.io/en/latest/EN/Configuration/Config-Builder.html#insulin - Sensitivity Plugins - Check all correct answers. - Sensitivity plugins allow AAPS to adjust for temporary or short-lived changes in insulin sensitivity (for example hormonal changes or issues with absorption at the infusion site). - Sensitivity plugins provide the user with suggested changes to basal rates, I:C ratios and ISF that can be used to edit profile. - Logging a cannula change will reset Autosens ratio back to 100%. - Some of the plugin options have configurable time ranges that can be set by the user. - https://androidaps.readthedocs.io/en/latest/EN/Configuration/Sensitivity-detection-and-COB.html - https://androidaps.readthedocs.io/en/latest/Usage/Open-APS-features.html?highlight=Autosens#autosens - Carb Entry Errors - What should you do if you’ve made an incorrect carb entry? - Delete the incorrect entry in Treatments and enter the correct new carb value. - Bolus with insulin using the infusion set prime menu. - Do nothing – AAPS will make the appropriate adjustments. - Bolus with insulin using the Insulin (bolus) button in Overview. - Insulin delivery/entry errors - What should you do if you received less insulin than the pump history suggests e.g. due to an occlusion, a failed cannula or forgetting to reattach the pump after a shower?  - Delete insulin data from Nightscout Careportal to remove it from the pump history. - Compare values in AAPS and pump history (if pump supports this). - Bolus a proportion of your calculated ‘missed’ insulin by either syringe/pen or using a prime. - Do nothing and allow AAPS to correct any resulting high blood glucose level. - Carbs on Board (COB) - How changing ISF value affects COB calculation? - Increasing ISF will take absorbing carbs a longer time - Increasing ISF will take absorbing carbs a shorter time - Increasing ISF will not affect calculated carbs absorption - How changing IC value affects COB calculation? - Increasing IC will take absorbing carbs a longer time - Increasing IC will take absorbing carbs a shorter time - Increasing IC will not affect calculated carbs absorption - How changing profile percentage affects COB calculation? - Setting profile to 150% will take absorbing carbs a longer time - Setting profile to 150% will take absorbing carbs a shorter time - Setting profile to 150% will not affect calculated carbs absorption - Insulin on Board (IOB) - IOB value is affected by issued temporary basals. - High temp basal will not be given when your blood sugar is below target. - Negative IOB for a substantial period in the absence of exercise suggests your profile is too strong and less insulin is needed in your settings. - Positive IOB for a substantial period suggests insulin resistance or unannounced meals. - Carb entry and boluses - Only grams should be used for estimating and recording carbohydrates consumed. - Carbohydrates consumed can be recorded using an appropriate exchange system (e.g. DAFNE "CHO" exchanges or European "Bread Units"). - AAPS uses a dynamic model to estimate carb “decay” and calculate COB. - If blood glucose levels are outside acceptable values (too low or too high) the bolus calculator can be used to provide suggestions for carb or insulin corrections. - https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/FAQ.html#insulin-to-carb-ratio-ic-g-u - e-carbs - What could you use e-carbs (extended carbs) for? - To schedule carbs in the future, possibly distributed over an interval (similar to an extended bolus distributing insulin over an interval). - For logging \'free\' exercise carbs you want to hide from AAPS. - e-carbs (distributed in the future) can assist AAPS in dealing with high fat/protein meals. - For logging rescue carbs you use to treat low blood glucose.  - https://androidaps.readthedocs.io/en/latest/EN/Usage/Extended-Carbs.html - Remote Monitoring - How can you monitor AAPS (for example for your child) remotely? - AAPSClient app, Nightscout app and Nightscout webpage all allow you to follow AAPS remotely. - Other apps (e.g. Dexcom follow, xDrip running in follow mode) allow you to follow some parameters (e.g. blood glucose/sensor values) remotely, but use different algorithms so may have inaccurate IOB or COB values. - To follow AAPS remotely, both devices must have internet access (e.g. via Wi-Fi or mobile/cellular network data). - AAPSClient used as a remote follower will both monitor and provide full control of AAPS. - https://androidaps.readthedocs.io/en/latest/EN/Children/Children.html - Insulin Sensitivity Factor (ISF) - Raising ISF values will lead to more insulin delivery to cover a specific amount of carbs. - Reducing ISF values lead to more insulin delivery to correct for an above target blood glucose. - Raising or lowering ISF has no effect on insulin delivery when blood glucose levels are below target. - ISF should be entered in your AAPS Preferences. - Changing the ISF value in your profile is enough to apply the change. - https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/FAQ.html#insulin-sensitivity-factor-isf-mmol-l-u-or-mg-dl-u - https://androidaps.readthedocs.io/en/latest/EN/Usage/Profiles.html - You can use more than one value for I:C ratio in your profile. - If you change your ISF in your profile you should always change your I:C ratio too. - Insulin to Carbohydrate Ratio (I:C ratio) - Higher I:C ratios lead to less insulin delivered for a given amount of carbs. - Lower I:C ratios lead to less insulin delivered for a given amount of carbs. - If you have 0 COB, changing the IC ratio will lead to a different amount of insulin to correct a given BG value. - IC will be different if you count bread (exchange) unit as 10g or 12g. - IC meaning is: How many bread (exchange) units are covered by 1U of insulin. - https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/FAQ.html#carbohydrate-to-insulin-ratio-cr-g-u - Profile Switching - When specifying a 90% profile switch, which answers are true? - Basal rates will be 10% lower. - ISF will be 10% higher. - The value of the I:C ratio will be a 10% lower number. - ISF and I:C ratios will be unchanged. - https://androidaps.readthedocs.io/en/latest/EN/Usage/Profiles.html?highlight=profile%20switch#profile-switch - Profile Switching - When specifying a 120% profile switch, which answers are true? - Target blood glucose will be 20% higher. - Basal rates will be 20% higher. - Target blood glucose will be unchanged. - ISF will be 20% higher. - Profile Switching - If you get up 2 hours earlier than usual, how should you notify AAPS of the change in your schedule? - Initiate a profile switch with a timeshift of 2 - Initiate a profile switch with a timeshift of -2 - Set an eating soon temporary target. - Do a profile switch to more than 100%.  - https://androidaps.readthedocs.io/en/latest/EN/Usage/Profiles.html?highlight=profile%20switch#timeshift - Changes to profiles - Basal rates, ISF, I:C ratios, etc., should be set in profiles. - Activating changes to your Nightscout Profile requires your AAPS phone to have an internet connection. - Editing profiles to change values is sufficient to enact any changes made. - Multiple profiles can be set up and selected to accommodate changing circumstances (e.g. hormonal changes, shift working, weekdays/weekend lifestyle). - https://androidaps.readthedocs.io/en/latest/EN/Module/module.html#good-individual-dosage-algorithm-for-your-diabetes-therapy - Help with basal rates - Where to go for help with basalrate etc. - Your diabetes team - Google - Facebook - - Other Medication. Please read the statement below and then check the box to accept the declaration. - AAPS reduces basal rates or suspends insulin delivery to raise blood sugar. Drugs in the class SGLT2 inhibitors (gliflozins) can prevent increases in blood glucose and therefore can produce a dangerous insulin deficiency leading to DKA. -\nCommon brand names are: Invokana®, Forxiga®, Jardiance®, Steglatro®, Suglat®, Apleway®, Deberza®, Synjardy®, Vokanamet®, Xigduo®.\n\nI hereby promise that I will not take such drugs when using AAPS or will deactivate the loop before using such drugs. - diff --git a/app/src/main/res/values/objectives.xml b/app/src/main/res/values/objectives.xml index e8419700a8..045e125f3d 100644 --- a/app/src/main/res/values/objectives.xml +++ b/app/src/main/res/values/objectives.xml @@ -1,62 +1,3 @@ - ObjectivesActionsUsed - ObjectivesLoopUsed - ObjectivesScaleUsed - objectives_request_code - ObjectivesmanualEnacts - - Start - Verify - %1$d. Objective - Objective %1$d not started - Objective %1$d not finished - Setting up visualization and monitoring, and analyzing basals and ratios - Verify that BG is available in Nightscout, and pump insulin data is being uploaded - Starting on an open loop - Run in Open Loop mode for a few days and manually enact lots of temp basals. Set up and use temporary and default temporary targets (e.g. for activity or hypo treatment carbs) - Understanding your open loop, including its temp basal recommendations - Based on that experience, decide what max basal should be, and set it on the pump and preferences - Starting to close the loop with Low Glucose Suspend - Run in closed loop with max IOB = 0 for a few days without too many LGS events - Tuning the closed loop, raising max IOB above 0 and gradually lowering BG targets - Run for a few days, and at least one night with no low BG alarms, before dropping BG - Adjust basals and ratios if needed, and then enable auto-sens - 1 week successful daytime looping with regular carb entry - Enabling additional features for daytime use, such as SMB - Enabling automation - You must read the wiki and rise maxIOB to get SMBs working fine! A good start is maxIOB=average mealbolus + 3 x max daily basal - Read the docs on how automation works. Set up your first simple rules. Instead of action let AAPS display only notification. When you are sure automation is triggered at the right time replace notification by real action. (https://androidaps.readthedocs.io/en/latest/EN/Usage/Automation.html) - BG available in NS - Pump status available in NS - Manual enacts - Accomplished: %1$s - Learn how to control AAPS - Perform different actions in AAPS - Set profile 90% for 10 min (Long-press profile name on Overview) - Simulate shower. Disconnect pump for 1h (Long-press on Open Loop) - ... and reconnect back the same way - Create custom temporary target with 10 min duration (Long-press on your current target) - In Config Builder enable Actions plugin, make it visible and display its content from top menu - Display content of Loop plugin - Use scale function by long-pressing BG chart - Enter - If you have at least 3 months of closed loop experience with other systems you might qualify for a code to skip objectives. See https://androidaps.readthedocs.io/en/latest/EN/Usage/Objectives.html#skip-objectives for details. - Code accepted - Code invalid - Prove your knowledge - Study the questions.  You are given four possible answers for each question. There may be more than one correct answer. Please check all those that are correct and select VERIFY. - Answering disabled until: %1$s - Wrong answer! - Next unfinished - Request code: %1$s - (check all correct answers) - https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/FAQ.html#what-to-do-when-taking-a-shower-or-bath - https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/Screenshots.html#the-homescreen - https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/Screenshots.html#config-builder - https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/Screenshots.html#the-homescreen - Not connected to the internet - Failed retrieve time - Objective requirements not met - diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index fdd4bfe4bf..721c727511 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -35,9 +35,6 @@ bolussnooze_dia_divisor autosens_adjust_targets last_cleanup_run - Treatments safety - Max allowed bolus [U] - Max allowed carbs [g] BG level below which low glucose suspend occurs %1$s Preferences Preferences @@ -45,9 +42,7 @@ Reset Databases Do you really want to reset the databases? Exit - Some buttons to quickly access common features Used for configuring the active plugins - Learning program Activate or deactivate the implementation triggering the loop. State of the algorithm in 2017 Most recent algorithm for advanced users @@ -92,20 +87,14 @@ After processed constraints Temp basal set by pump NO APS SELECTED OR PROVIDED RESULT - Safety Plugin is disabled Constraints violation - Accept new temp basal: Change your input! BG Source Where should AAPS gain it\'s data from? - APS Mode New suggestion available Carbs Suggestion - Carb time Profile - TempBasal - Extended Bolus Nightscout version: Preferences exported User Entries exported @@ -141,7 +130,6 @@ I UNDERSTAND AND AGREE Save Reload profile - QuickWizard QuickWizard settings Button text: Carbs: @@ -149,7 +137,6 @@ Add Edit Corr - Actions (DANGEROUS TO DISABLE) NS upload only NS upload only (disabled sync). Not effective on SGV unless a local source like xDrip+ is selected. Not effective on Profiles while NS-Profiles is used.\n!!! WARNING !!! Disabling this option may cause malfunctions and insulin overdose if any of your component (AAPS, NS, xDrip+) is wrong configured. Carefully watch if data displayed by AAPS match the pump state! Pump not initialized! @@ -161,7 +148,6 @@ Wear Resend All Data Open Settings on Wear - Basal rate Ongoing Notification OLD DATA OpenAPS AMA @@ -169,14 +155,12 @@ Autosens data Script debug Use Autosens feature - ACT CONF LOOP OAPS DYNISF HOME TREAT - OBJ WEAR Shorten tab titles Always use short average delta instead of simple delta @@ -195,22 +179,9 @@ Executing Wear settings not successful - please check phone - Patient type - Child - Teenage - Adult - Insulin resistant adult - Pregnancy - Please select patient type to setup safety limits Patient name Please provide patient name or nickname to differentiate among multiple setups I_understand - 15 mins - 30 mins - 1 hour - 2 hours - 3 hours - 10 hours Exiting application to apply settings. Which type of insulin are you using? Enable superbolus in wizard @@ -224,13 +195,7 @@ DEVSLOPE About Missing phone state permission - Cancel Extended Bolus Do Profile Switch - Sensor - Insulin - Pump battery - age: - level: Alarm options ns_announcements ns_alarms @@ -264,15 +229,12 @@ DynISFAdjust DynamicISF Adjustment Factor % Adjustment factor for DynamicISF. Set more than 100% for more aggressive correction doses, and less than 100% for less aggressive corrections. - use_smb - use_uam smb_enable_carbs_suggestions_threshold Enable UAM Enable SMB Use Super Micro Boluses instead of temp basal for faster action Detection of Unannounced meals INVALID - Percentage Default Temp-Targets eatingsoon duration eatingsoon target @@ -308,13 +270,6 @@ COB calculation Temporary target calculation Percentage calculation - Loop enabled - APS selected - Synchronization service has write permission - Closed mode enabled - Maximal IOB set properly - BG available from selected source - Extended bolus delivery error enableSMB_always enableSMB_with_COB enableSMB_with_temptarget @@ -342,11 +297,9 @@ Number of carbs to add when button is pressed Amount of insulin to add when button is pressed Could not launch CGM application. Make sure it is installed. - CGM Ignore 5m Ignore 15m Ignore 30m - History browser Notify on SMB Show SMB on the watch like a standard bolus. Show the predictions on the watchface. @@ -364,34 +317,10 @@ Carbs On Board Insulin On Board Basals - Running dev version. Closed loop is disabled. Engineering mode enabled - Pump is not temp basal capable - Closed loop mode disabled in preferences - Autosens disabled in preferences - SMB disabled in preferences - UAM disabled in preferences - UAM disabled because it rely on Oref1 sensitivity plugin - openapsma_max_basal - openapsama_current_basal_safety_multiplier - openapsama_max_daily_safety_multiplier - max basal multiplier - max daily basal multiplier - openapsma_max_iob A bolus was delivered within the last 3 minutes, skipping SMB Basal set correctly - treatmentssafety_maxbolus - lgsThreshold - Limiting extended bolus to %1$.1f U because of %2$s - Limiting carbs to %1$d g because of %2$s - Limiting IOB to %1$.1f U because of %2$s - max value in preferences - hard limit - openapsama_useautosens - SMB always and after carbs disabled because active BG source doesn\'t support advanced filtering - SMB not allowed in open loop mode IobCobCalculator - openapsmb_max_iob Maximum total IOB OpenAPS can\'t go over [U] 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] @@ -486,23 +415,15 @@ smbmaxminutes uamsmbmaxminutes Bolus wizard performs calculation but only this part of calculated insulin is delivered. Useful with SMB algorithm. - Increasing max basal value because setting is lower than your max basal in profile Units - Clear finished - Clear started - Do you want reset objective start? You may lose your progress. Select units you want to display values in wear_detailediob wear_showbgi Lower value of in range area (display only) Higher value of in range area (display only) - Tools - Show calcuation Show removed Clear queue? All data in queue will be lost! wear_detailed_delta - Use of Extended bolus feature will stop closed loop mode for the time of running extended bolus. Do you really want it? - Closed loop disabled because of running Extended bolus Chart menu Data Broadcaster SMB request time @@ -517,12 +438,6 @@ Absolute insulin Master password is used for backup encryption and to override security in application. Remember it or store on a safe place. Current master password - Original skin - Low Resolution skin - Buttons are always displayed on bottom of screen - Large display - skin - Skin RileyLink status: Unable to create profile. Profile is invalid. Don\'t kill my app? @@ -531,7 +446,6 @@ Use reminder to bolus later with wizard ("post-bolus") Crash logs upload disabled! Graph - Chart menu Clear filter Cannula Use values of your largest food you usually eat\n @@ -541,19 +455,10 @@ You can provide optional email address if you want to be notified about app crashes. This is not an automated service. You will be contacted by developers in dangerous situations. BG data status Remove BG readings - cannula age - patch pump age - Patch pump Identification (email, FB or Discord nick etc) Identification not set in dev mode dialog - current blood glucose Not available - graph - blood glucose quality - insulin - blood glucose - outdated Temptarget unknown preset: %1$s Cancelling running Temp-Targets? @@ -577,7 +482,6 @@ Loop status Graph scale open settings - set carb timer alarm All Phone Watch diff --git a/app/src/main/res/xml/pref_general.xml b/app/src/main/res/xml/pref_general.xml index 2b30903a26..63a8db89ef 100644 --- a/app/src/main/res/xml/pref_general.xml +++ b/app/src/main/res/xml/pref_general.xml @@ -97,7 +97,7 @@ - diff --git a/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt b/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt index 40b8329999..7bdd30a68f 100644 --- a/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt @@ -14,9 +14,6 @@ import info.nightscout.androidaps.insight.database.InsightDbHelper import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin import info.nightscout.androidaps.plugins.aps.openAPSSMBDynamicISF.OpenAPSSMBDynamicISFPlugin -import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesPlugin -import info.nightscout.androidaps.plugins.constraints.objectives.objectives.Objective -import info.nightscout.androidaps.plugins.constraints.safety.SafetyPlugin import info.nightscout.androidaps.plugins.general.maintenance.PrefFileListProvider import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider import info.nightscout.androidaps.plugins.pump.combo.ComboPlugin @@ -25,19 +22,23 @@ import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInf import info.nightscout.androidaps.plugins.pump.common.bolusInfo.TemporaryBasalStorage import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin -import info.nightscout.plugins.source.GlimpPlugin import info.nightscout.androidaps.utils.Profiler import info.nightscout.androidaps.utils.buildHelper.BuildHelperImpl import info.nightscout.database.impl.AppRepository import info.nightscout.implementation.constraints.ConstraintsImpl import info.nightscout.interfaces.BuildHelper import info.nightscout.interfaces.constraints.Constraint +import info.nightscout.interfaces.constraints.Objectives import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginType import info.nightscout.interfaces.pump.PumpSync import info.nightscout.interfaces.pump.defs.PumpDescription import info.nightscout.interfaces.utils.HardLimits +import info.nightscout.plugins.constraints.objectives.ObjectivesPlugin +import info.nightscout.plugins.constraints.objectives.objectives.Objective +import info.nightscout.plugins.constraints.safety.SafetyPlugin import info.nightscout.plugins.pump.virtual.VirtualPumpPlugin +import info.nightscout.plugins.source.GlimpPlugin import info.nightscout.shared.sharedPreferences.SP import org.junit.Assert import org.junit.Before @@ -210,7 +211,8 @@ class ConstraintsCheckerTest : TestBaseWithProfile() { fabricPrivacy, dateUtil, repository, - glucoseStatusProvider + glucoseStatusProvider, + sp ) safetyPlugin = SafetyPlugin( @@ -220,10 +222,6 @@ class ConstraintsCheckerTest : TestBaseWithProfile() { sp, rxBus, constraintChecker, - openAPSAMAPlugin, - openAPSSMBPlugin, - openAPSSMBDynamicISFPlugin, - sensitivityOref1Plugin, activePlugin, hardLimits, BuildHelperImpl(config, fileListProvider), @@ -238,6 +236,7 @@ class ConstraintsCheckerTest : TestBaseWithProfile() { constraintsPluginsList.add(danaRPlugin) constraintsPluginsList.add(danaRSPlugin) constraintsPluginsList.add(insightPlugin) + constraintsPluginsList.add(openAPSAMAPlugin) constraintsPluginsList.add(openAPSSMBPlugin) `when`(activePlugin.getSpecificPluginsListByInterface(Constraints::class.java)).thenReturn(constraintsPluginsList) objectivesPlugin.onStart() @@ -260,7 +259,7 @@ class ConstraintsCheckerTest : TestBaseWithProfile() { @Test fun isClosedLoopAllowedTest() { `when`(sp.getString(R.string.key_aps_mode, "open")).thenReturn("closed") - objectivesPlugin.objectives[ObjectivesPlugin.MAXIOB_ZERO_CL_OBJECTIVE].startedOn = 0 + objectivesPlugin.objectives[Objectives.MAXIOB_ZERO_CL_OBJECTIVE].startedOn = 0 var c: Constraint = constraintChecker.isClosedLoopAllowed() aapsLogger.debug("Reason list: " + c.reasonList.toString()) // Assert.assertTrue(c.reasonList[0].toString().contains("Closed loop is disabled")) // Safety & Objectives @@ -275,7 +274,7 @@ class ConstraintsCheckerTest : TestBaseWithProfile() { // Safety & Objectives @Test fun isAutosensModeEnabledTest() { - objectivesPlugin.objectives[ObjectivesPlugin.AUTOSENS_OBJECTIVE].startedOn = 0 + objectivesPlugin.objectives[Objectives.AUTOSENS_OBJECTIVE].startedOn = 0 `when`(sp.getBoolean(R.string.key_openapsama_useautosens, false)).thenReturn(false) val c = constraintChecker.isAutosensModeEnabled() Assert.assertEquals(true, c.reasonList.size == 2) // Safety & Objectives @@ -304,7 +303,7 @@ class ConstraintsCheckerTest : TestBaseWithProfile() { // Safety & Objectives @Test fun isSMBModeEnabledTest() { - objectivesPlugin.objectives[ObjectivesPlugin.SMB_OBJECTIVE].startedOn = 0 + objectivesPlugin.objectives[Objectives.SMB_OBJECTIVE].startedOn = 0 `when`(sp.getBoolean(R.string.key_use_smb, false)).thenReturn(false) `when`(sp.getString(R.string.key_aps_mode, "open")).thenReturn("open") // `when`(constraintChecker.isClosedLoopAllowed()).thenReturn(Constraint(true)) @@ -423,7 +422,7 @@ class ConstraintsCheckerTest : TestBaseWithProfile() { val d = constraintChecker.getMaxIOBAllowed() Assert.assertEquals(1.5, d.value(), 0.01) Assert.assertEquals(d.reasonList.toString(), 2, d.reasonList.size) - Assert.assertEquals("Safety: Limiting IOB to 1.5 U because of max value in preferences", d.getMostLimitedReasons(aapsLogger)) + Assert.assertEquals("OpenAPSAMA: Limiting IOB to 1.5 U because of max value in preferences", d.getMostLimitedReasons(aapsLogger)) } @Test @@ -439,6 +438,6 @@ class ConstraintsCheckerTest : TestBaseWithProfile() { val d = constraintChecker.getMaxIOBAllowed() Assert.assertEquals(3.0, d.value(), 0.01) Assert.assertEquals(d.reasonList.toString(), 2, d.reasonList.size) - Assert.assertEquals("Safety: Limiting IOB to 3.0 U because of max value in preferences", d.getMostLimitedReasons(aapsLogger)) + Assert.assertEquals("OpenAPSSMB: Limiting IOB to 3.0 U because of max value in preferences", d.getMostLimitedReasons(aapsLogger)) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/safety/SafetyPluginTest.kt similarity index 76% rename from app/src/test/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPluginTest.kt rename to app/src/test/java/info/nightscout/androidaps/plugins/safety/SafetyPluginTest.kt index 7f7190c234..47b102b536 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/safety/SafetyPluginTest.kt @@ -1,24 +1,26 @@ -package info.nightscout.androidaps.plugins.constraints.safety +package info.nightscout.androidaps.plugins.safety import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.androidaps.HardLimitsMock -import info.nightscout.androidaps.R import info.nightscout.androidaps.TestBaseWithProfile import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.interfaces.Constraints import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin -import info.nightscout.androidaps.plugins.aps.openAPSSMBDynamicISF.OpenAPSSMBDynamicISFPlugin -import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin -import info.nightscout.plugins.source.GlimpPlugin +import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider +import info.nightscout.androidaps.utils.Profiler import info.nightscout.database.impl.AppRepository import info.nightscout.interfaces.BuildHelper import info.nightscout.interfaces.Constants import info.nightscout.interfaces.constraints.Constraint +import info.nightscout.interfaces.plugin.PluginType import info.nightscout.interfaces.pump.defs.PumpDescription import info.nightscout.interfaces.utils.HardLimits +import info.nightscout.plugins.R +import info.nightscout.plugins.constraints.safety.SafetyPlugin import info.nightscout.plugins.pump.virtual.VirtualPumpPlugin +import info.nightscout.plugins.source.GlimpPlugin import info.nightscout.shared.sharedPreferences.SP import org.junit.Assert import org.junit.Before @@ -30,20 +32,20 @@ class SafetyPluginTest : TestBaseWithProfile() { @Mock lateinit var sp: SP @Mock lateinit var constraintChecker: Constraints - @Mock lateinit var openAPSAMAPlugin: OpenAPSAMAPlugin - @Mock lateinit var openAPSSMBPlugin: OpenAPSSMBPlugin - @Mock lateinit var openAPSSMBDynamicISFPlugin: OpenAPSSMBDynamicISFPlugin - @Mock lateinit var sensitivityOref1Plugin: SensitivityOref1Plugin @Mock lateinit var activePlugin: ActivePlugin @Mock lateinit var buildHelper: BuildHelper @Mock lateinit var virtualPumpPlugin: VirtualPumpPlugin @Mock lateinit var glimpPlugin: GlimpPlugin + @Mock lateinit var profiler: Profiler @Mock lateinit var repository: AppRepository + @Mock lateinit var glucoseStatusProvider: GlucoseStatusProvider private lateinit var hardLimits: HardLimits private lateinit var safetyPlugin: SafetyPlugin + private lateinit var openAPSAMAPlugin: OpenAPSAMAPlugin + private lateinit var openAPSSMBPlugin: OpenAPSSMBPlugin - val injector = HasAndroidInjector { AndroidInjector { } } + private val injector = HasAndroidInjector { AndroidInjector { } } private val pumpDescription = PumpDescription() @Before @@ -67,19 +69,21 @@ class SafetyPluginTest : TestBaseWithProfile() { `when`(rh.gs(R.string.smbalwaysdisabled)).thenReturn("SMB always and after carbs disabled because active BG source doesn\\'t support advanced filtering") `when`(rh.gs(R.string.smbnotallowedinopenloopmode)).thenReturn("SMB not allowed in open loop mode") `when`(rh.gs(R.string.key_child)).thenReturn("child") + `when`(rh.gs(R.string.lowglucosesuspend)).thenReturn("Low Glucose Suspend") `when`(activePlugin.activePump).thenReturn(virtualPumpPlugin) `when`(virtualPumpPlugin.pumpDescription).thenReturn(pumpDescription) `when`(config.APS).thenReturn(true) hardLimits = HardLimitsMock(sp, rh) - safetyPlugin = SafetyPlugin( - injector, aapsLogger, rh, sp, rxBus, constraintChecker, openAPSAMAPlugin, openAPSSMBPlugin, openAPSSMBDynamicISFPlugin, sensitivityOref1Plugin, activePlugin, - hardLimits, buildHelper, - iobCobCalculator, config, dateUtil - ) + safetyPlugin = SafetyPlugin(injector, aapsLogger, rh, sp, rxBus, constraintChecker, activePlugin, hardLimits, buildHelper, iobCobCalculator, config, dateUtil) + openAPSAMAPlugin = OpenAPSAMAPlugin(injector, aapsLogger, rxBus, constraintChecker, rh, profileFunction, context, activePlugin, iobCobCalculator, hardLimits, profiler, fabricPrivacy, + dateUtil, repository, glucoseStatusProvider, sp) + openAPSSMBPlugin = OpenAPSSMBPlugin(injector, aapsLogger, rxBus, constraintChecker, rh, profileFunction, context, activePlugin, iobCobCalculator, hardLimits, profiler, sp, + dateUtil, repository, glucoseStatusProvider) } - @Test fun pumpDescriptionShouldLimitLoopInvocation() { + @Test + fun pumpDescriptionShouldLimitLoopInvocation() { pumpDescription.isTempBasalCapable = false var c = Constraint(true) c = safetyPlugin.isLoopInvocationAllowed(c) @@ -87,7 +91,8 @@ class SafetyPluginTest : TestBaseWithProfile() { Assert.assertEquals(false, c.value()) } - @Test fun disabledEngineeringModeShouldLimitClosedLoop() { + @Test + fun disabledEngineeringModeShouldLimitClosedLoop() { `when`(sp.getString(R.string.key_aps_mode, "open")).thenReturn("closed") `when`(buildHelper.isEngineeringModeOrRelease()).thenReturn(false) var c = Constraint(true) @@ -96,7 +101,8 @@ class SafetyPluginTest : TestBaseWithProfile() { Assert.assertEquals(false, c.value()) } - @Test fun setOpenLoopInPreferencesShouldLimitClosedLoop() { + @Test + fun setOpenLoopInPreferencesShouldLimitClosedLoop() { `when`(sp.getString(R.string.key_aps_mode, "open")).thenReturn("open") var c = Constraint(true) c = safetyPlugin.isClosedLoopAllowed(c) @@ -104,7 +110,8 @@ class SafetyPluginTest : TestBaseWithProfile() { Assert.assertEquals(false, c.value()) } - @Test fun notEnabledSMBInPreferencesDisablesSMB() { + @Test + fun notEnabledSMBInPreferencesDisablesSMB() { `when`(sp.getBoolean(R.string.key_use_smb, false)).thenReturn(false) `when`(constraintChecker.isClosedLoopAllowed(anyObject())).thenReturn(Constraint(true)) var c = Constraint(true) @@ -113,7 +120,8 @@ class SafetyPluginTest : TestBaseWithProfile() { Assert.assertEquals(false, c.value()) } - @Test fun openLoopPreventsSMB() { + @Test + fun openLoopPreventsSMB() { `when`(sp.getBoolean(R.string.key_use_smb, false)).thenReturn(true) `when`(constraintChecker.isClosedLoopAllowed(anyObject())).thenReturn(Constraint(false)) var c = Constraint(true) @@ -122,7 +130,8 @@ class SafetyPluginTest : TestBaseWithProfile() { Assert.assertEquals(false, c.value()) } - @Test fun bgSourceShouldPreventSMBAlways() { + @Test + fun bgSourceShouldPreventSMBAlways() { `when`(activePlugin.activeBgSource).thenReturn(glimpPlugin) var c = Constraint(true) c = safetyPlugin.isAdvancedFilteringEnabled(c) @@ -130,7 +139,8 @@ class SafetyPluginTest : TestBaseWithProfile() { Assert.assertEquals(false, c.value()) } - @Test fun basalRateShouldBeLimited() { + @Test + fun basalRateShouldBeLimited() { `when`(sp.getDouble(R.string.key_openapsma_max_basal, 1.0)).thenReturn(1.0) `when`(sp.getDouble(R.string.key_openapsama_current_basal_safety_multiplier, 4.0)).thenReturn(4.0) `when`(sp.getDouble(R.string.key_openapsama_max_daily_safety_multiplier, 3.0)).thenReturn(3.0) @@ -149,7 +159,8 @@ class SafetyPluginTest : TestBaseWithProfile() { Assert.assertEquals("Safety: Limiting max basal rate to 1.00 U/h because of max value in preferences", c.getMostLimitedReasons(aapsLogger)) } - @Test fun doNotAllowNegativeBasalRate() { + @Test + fun doNotAllowNegativeBasalRate() { `when`(sp.getString(R.string.key_age, "")).thenReturn("child") val d = Constraint(-0.5) safetyPlugin.applyBasalConstraints(d, validProfile) @@ -162,7 +173,8 @@ class SafetyPluginTest : TestBaseWithProfile() { ) } - @Test fun percentBasalRateShouldBeLimited() { + @Test + fun percentBasalRateShouldBeLimited() { // No limit by default `when`(sp.getDouble(R.string.key_openapsma_max_basal, 1.0)).thenReturn(1.0) `when`(sp.getDouble(R.string.key_openapsama_current_basal_safety_multiplier, 4.0)).thenReturn(4.0) @@ -185,7 +197,8 @@ class SafetyPluginTest : TestBaseWithProfile() { Assert.assertEquals("Safety: Limiting max percent rate to 100% because of pump limit", i.getMostLimitedReasons(aapsLogger)) } - @Test fun doNotAllowNegativePercentBasalRate() { + @Test + fun doNotAllowNegativePercentBasalRate() { `when`(sp.getString(R.string.key_age, "")).thenReturn("child") val i = Constraint(-22) safetyPlugin.applyBasalPercentConstraints(i, validProfile) @@ -201,7 +214,8 @@ class SafetyPluginTest : TestBaseWithProfile() { Assert.assertEquals("Safety: Limiting max percent rate to 0% because of pump limit", i.getMostLimitedReasons(aapsLogger)) } - @Test fun bolusAmountShouldBeLimited() { + @Test + fun bolusAmountShouldBeLimited() { `when`(sp.getDouble(R.string.key_treatmentssafety_maxbolus, 3.0)).thenReturn(3.0) `when`(sp.getString(R.string.key_age, "")).thenReturn("child") var d = Constraint(Constants.REALLYHIGHBOLUS) @@ -216,7 +230,8 @@ class SafetyPluginTest : TestBaseWithProfile() { Assert.assertEquals("Safety: Limiting bolus to 3.0 U because of max value in preferences", d.getMostLimitedReasons(aapsLogger)) } - @Test fun doNotAllowNegativeBolusAmount() { + @Test + fun doNotAllowNegativeBolusAmount() { `when`(sp.getDouble(R.string.key_treatmentssafety_maxbolus, 3.0)).thenReturn(3.0) `when`(sp.getString(R.string.key_age, "")).thenReturn("child") var d = Constraint(-22.0) @@ -226,7 +241,8 @@ class SafetyPluginTest : TestBaseWithProfile() { Assert.assertEquals("Safety: Limiting bolus to 0.0 U because of it must be positive value", d.getMostLimitedReasons(aapsLogger)) } - @Test fun carbsAmountShouldBeLimited() { + @Test + fun carbsAmountShouldBeLimited() { // No limit by default `when`(sp.getInt(R.string.key_treatmentssafety_maxcarbs, 48)).thenReturn(48) @@ -242,10 +258,13 @@ class SafetyPluginTest : TestBaseWithProfile() { Assert.assertEquals("Safety: Limiting carbs to 48 g because of max value in preferences", i.getReasons(aapsLogger)) } - @Test fun iobShouldBeLimited() { - `when`(openAPSSMBPlugin.isEnabled()).thenReturn(true) - `when`(openAPSAMAPlugin.isEnabled()).thenReturn(false) - `when`(sp.getString(R.string.key_aps_mode, "open")).thenReturn("closed") + @Test + fun iobShouldBeLimited() { + openAPSAMAPlugin.setPluginEnabled(PluginType.APS, true) + openAPSSMBPlugin.setPluginEnabled(PluginType.APS, true) + //`when`(openAPSSMBPlugin.isEnabled()).thenReturn(true) + //`when`(openAPSAMAPlugin.isEnabled()).thenReturn(false) + `when`(sp.getString(R.string.key_aps_mode, "open")).thenReturn("lgs") `when`(sp.getDouble(R.string.key_openapsma_max_iob, 1.5)).thenReturn(1.5) `when`(sp.getDouble(R.string.key_openapssmb_max_iob, 3.0)).thenReturn(3.0) `when`(sp.getString(R.string.key_age, "")).thenReturn("teenage") @@ -253,8 +272,22 @@ class SafetyPluginTest : TestBaseWithProfile() { // Apply all limits var d = Constraint(Constants.REALLYHIGHIOB) d = safetyPlugin.applyMaxIOBConstraints(d) - Assert.assertEquals(3.0, d.value(), 0.01) - Assert.assertEquals("Safety: Limiting IOB to 3.0 U because of max value in preferences\nSafety: Limiting IOB to 22.0 U because of hard limit", d.getReasons(aapsLogger)) - Assert.assertEquals("Safety: Limiting IOB to 3.0 U because of max value in preferences", d.getMostLimitedReasons(aapsLogger)) + Assert.assertEquals(HardLimits.MAX_IOB_LGS, d.value(), 0.01) + Assert.assertEquals("Safety: Limiting IOB to 0.0 U because of Low Glucose Suspend", d.getReasons(aapsLogger)) + Assert.assertEquals("Safety: Limiting IOB to 0.0 U because of Low Glucose Suspend", d.getMostLimitedReasons(aapsLogger)) + + // Apply all limits + d = Constraint(Constants.REALLYHIGHIOB) + val a = openAPSAMAPlugin.applyMaxIOBConstraints(d) + Assert.assertEquals(1.5, a.value(), 0.01) + Assert.assertEquals("OpenAPSAMA: Limiting IOB to 1.5 U because of max value in preferences\nOpenAPSAMA: Limiting IOB to 7.0 U because of hard limit", d.getReasons(aapsLogger)) + Assert.assertEquals("OpenAPSAMA: Limiting IOB to 1.5 U because of max value in preferences", d.getMostLimitedReasons(aapsLogger)) + + // Apply all limits + d = Constraint(Constants.REALLYHIGHIOB) + val s = openAPSSMBPlugin.applyMaxIOBConstraints(d) + Assert.assertEquals(3.0, s.value(), 0.01) + Assert.assertEquals("OpenAPSSMB: Limiting IOB to 3.0 U because of max value in preferences\nOpenAPSSMB: Limiting IOB to 22.0 U because of hard limit", d.getReasons(aapsLogger)) + Assert.assertEquals("OpenAPSSMB: Limiting IOB to 3.0 U because of max value in preferences", d.getMostLimitedReasons(aapsLogger)) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/utils/SntpClientTest.kt b/app/src/test/java/info/nightscout/androidaps/utils/SntpClientTest.kt index 7ead71d03d..fc9817d92a 100644 --- a/app/src/test/java/info/nightscout/androidaps/utils/SntpClientTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/utils/SntpClientTest.kt @@ -1,6 +1,7 @@ package info.nightscout.androidaps.utils import info.nightscout.androidaps.TestBase +import info.nightscout.plugins.constraints.objectives.SntpClient import info.nightscout.shared.utils.DateUtil import org.junit.Assert import org.junit.Test diff --git a/automation/src/main/java/info/nightscout/automation/actions/ActionStartTempTarget.kt b/automation/src/main/java/info/nightscout/automation/actions/ActionStartTempTarget.kt index 81b2db0d45..653f9c989a 100644 --- a/automation/src/main/java/info/nightscout/automation/actions/ActionStartTempTarget.kt +++ b/automation/src/main/java/info/nightscout/automation/actions/ActionStartTempTarget.kt @@ -79,7 +79,7 @@ class ActionStartTempTarget(injector: HasAndroidInjector) : Action(injector) { override fun generateDialog(root: LinearLayout) { val unitResId = if (value.units == GlucoseUnit.MGDL) R.string.mgdl else R.string.mmol LayoutBuilder() - .add(LabelWithElement(rh, rh.gs(R.string.careportal_temporarytarget) + "\n[" + rh.gs(unitResId) + "]", "", value)) + .add(LabelWithElement(rh, rh.gs(R.string.temporary_target) + "\n[" + rh.gs(unitResId) + "]", "", value)) .add(LabelWithElement(rh, rh.gs(R.string.duration_min_label), "", duration)) .build(root) } diff --git a/automation/src/main/java/info/nightscout/automation/triggers/TriggerTempTarget.kt b/automation/src/main/java/info/nightscout/automation/triggers/TriggerTempTarget.kt index 8d0884a9fc..ef4d1fbb3b 100644 --- a/automation/src/main/java/info/nightscout/automation/triggers/TriggerTempTarget.kt +++ b/automation/src/main/java/info/nightscout/automation/triggers/TriggerTempTarget.kt @@ -54,7 +54,7 @@ class TriggerTempTarget(injector: HasAndroidInjector) : Trigger(injector) { return this } - override fun friendlyName(): Int = R.string.careportal_temporarytarget + override fun friendlyName(): Int = R.string.temporary_target override fun friendlyDescription(): String = rh.gs(R.string.temptargetcompared, rh.gs(comparator.value.stringRes)) @@ -65,7 +65,7 @@ class TriggerTempTarget(injector: HasAndroidInjector) : Trigger(injector) { override fun generateDialog(root: LinearLayout) { LayoutBuilder() - .add(StaticLabel(rh, R.string.careportal_temporarytarget, this)) + .add(StaticLabel(rh, R.string.temporary_target, this)) .add(comparator) .build(root) } diff --git a/core/core-main/src/main/java/info/nightscout/androidaps/data/PumpEnactResultObject.kt b/core/core-main/src/main/java/info/nightscout/androidaps/data/PumpEnactResultObject.kt index 26a4bcbbf6..4da785da14 100644 --- a/core/core-main/src/main/java/info/nightscout/androidaps/data/PumpEnactResultObject.kt +++ b/core/core-main/src/main/java/info/nightscout/androidaps/data/PumpEnactResultObject.kt @@ -75,7 +75,7 @@ class PumpEnactResultObject(injector: HasAndroidInjector) : PumpEnactResult { isTempCancel -> { ret += "\n${rh.gs(R.string.enacted)}: $enacted" if (comment.isNotEmpty()) ret += "\n${rh.gs(R.string.comment)}: $comment" - ret += "\n${rh.gs(R.string.canceltemp)}" + ret += "\n${rh.gs(R.string.cancel_temp)}" } isPercent -> { @@ -113,7 +113,7 @@ class PumpEnactResultObject(injector: HasAndroidInjector) : PumpEnactResult { isTempCancel -> { ret += "
" + rh.gs(R.string.enacted) + ": " + enacted ret += "
" + rh.gs(R.string.comment) + ": " + comment + - "
" + rh.gs(R.string.canceltemp) + "
" + rh.gs(R.string.cancel_temp) } isPercent && percent != -1 -> { diff --git a/core/core-main/src/main/java/info/nightscout/androidaps/plugins/aps/loop/APSResult.kt b/core/core-main/src/main/java/info/nightscout/androidaps/plugins/aps/loop/APSResult.kt index 82591b0af5..3eed8d6746 100644 --- a/core/core-main/src/main/java/info/nightscout/androidaps/plugins/aps/loop/APSResult.kt +++ b/core/core-main/src/main/java/info/nightscout/androidaps/plugins/aps/loop/APSResult.kt @@ -102,7 +102,7 @@ open class APSResult @Inject constructor(val injector: HasAndroidInjector) { val pump = activePlugin.activePump if (isChangeRequested) { // rate - var ret: String = if (rate == 0.0 && duration == 0) "${rh.gs(R.string.canceltemp)} " + var ret: String = if (rate == 0.0 && duration == 0) "${rh.gs(R.string.cancel_temp)} " else if (rate == -1.0) "${rh.gs(R.string.let_temp_basal_run)}\n" else if (usePercent) "${rh.gs(R.string.rate)}: ${DecimalFormatter.to2Decimal(percent.toDouble())}% (${DecimalFormatter.to2Decimal(percent * pump.baseBasalRate / 100.0)} U/h) " + "${rh.gs(R.string.duration)}: ${DecimalFormatter.to2Decimal(duration.toDouble())} min " @@ -127,7 +127,7 @@ open class APSResult @Inject constructor(val injector: HasAndroidInjector) { val pump = activePlugin.activePump if (isChangeRequested) { // rate - var ret: String = if (rate == 0.0 && duration == 0) rh.gs(R.string.canceltemp) + "
" else if (rate == -1.0) rh.gs(R.string.let_temp_basal_run) + "
" else if (usePercent) "" + rh.gs(R.string.rate) + ": " + DecimalFormatter.to2Decimal(percent.toDouble()) + "% " + + var ret: String = if (rate == 0.0 && duration == 0) rh.gs(R.string.cancel_temp) + "
" else if (rate == -1.0) rh.gs(R.string.let_temp_basal_run) + "
" else if (usePercent) "" + rh.gs(R.string.rate) + ": " + DecimalFormatter.to2Decimal(percent.toDouble()) + "% " + "(" + DecimalFormatter.to2Decimal(percent * pump.baseBasalRate / 100.0) + " U/h)
" + "" + rh.gs(R.string.duration) + ": " + DecimalFormatter.to2Decimal(duration.toDouble()) + " min
" else "" + rh.gs(R.string.rate) + ": " + DecimalFormatter.to2Decimal(rate) + " U/h " + "(" + DecimalFormatter.to2Decimal(rate / pump.baseBasalRate * 100.0) + "%)
" + diff --git a/core/core-main/src/main/java/info/nightscout/androidaps/utils/Translator.kt b/core/core-main/src/main/java/info/nightscout/androidaps/utils/Translator.kt index 79ebf5557d..d0e3371554 100644 --- a/core/core-main/src/main/java/info/nightscout/androidaps/utils/Translator.kt +++ b/core/core-main/src/main/java/info/nightscout/androidaps/utils/Translator.kt @@ -138,16 +138,16 @@ class Translator @Inject internal constructor( TherapyEvent.Type.QUESTION -> rh.gs(R.string.careportal_question) TherapyEvent.Type.EXERCISE -> rh.gs(R.string.careportal_exercise) TherapyEvent.Type.CANNULA_CHANGE -> rh.gs(R.string.careportal_pump_site_change) - TherapyEvent.Type.PUMP_BATTERY_CHANGE -> rh.gs(R.string.careportal_pumpbatterychange) + TherapyEvent.Type.PUMP_BATTERY_CHANGE -> rh.gs(R.string.pump_battery_change) TherapyEvent.Type.SENSOR_STARTED -> rh.gs(R.string.careportal_cgmsensorstart) TherapyEvent.Type.SENSOR_STOPPED -> rh.gs(R.string.careportal_cgm_sensor_stop) - TherapyEvent.Type.SENSOR_CHANGE -> rh.gs(R.string.careportal_cgmsensorinsert) + TherapyEvent.Type.SENSOR_CHANGE -> rh.gs(R.string.cgm_sensor_insert) TherapyEvent.Type.INSULIN_CHANGE -> rh.gs(R.string.careportal_insulin_cartridge_change) TherapyEvent.Type.DAD_ALERT -> rh.gs(R.string.careportal_dad_alert) TherapyEvent.Type.TEMPORARY_BASAL_START -> rh.gs(R.string.careportal_tempbasalstart) TherapyEvent.Type.TEMPORARY_BASAL_END -> rh.gs(R.string.careportal_tempbasalend) TherapyEvent.Type.PROFILE_SWITCH -> rh.gs(R.string.careportal_profileswitch) - TherapyEvent.Type.TEMPORARY_TARGET -> rh.gs(R.string.careportal_temporarytarget) + TherapyEvent.Type.TEMPORARY_TARGET -> rh.gs(R.string.temporary_target) TherapyEvent.Type.TEMPORARY_TARGET_CANCEL -> rh.gs(R.string.careportal_temporarytargetcancel) TherapyEvent.Type.APS_OFFLINE -> rh.gs(R.string.careportal_openapsoffline) TherapyEvent.Type.NS_MBG -> rh.gs(R.string.careportal_mbg) diff --git a/core/core-main/src/main/java/info/nightscout/androidaps/utils/userEntry/UserEntryPresentationHelper.kt b/core/core-main/src/main/java/info/nightscout/androidaps/utils/userEntry/UserEntryPresentationHelper.kt index 8452ad84a8..6450da3daa 100644 --- a/core/core-main/src/main/java/info/nightscout/androidaps/utils/userEntry/UserEntryPresentationHelper.kt +++ b/core/core-main/src/main/java/info/nightscout/androidaps/utils/userEntry/UserEntryPresentationHelper.kt @@ -51,7 +51,7 @@ class UserEntryPresentationHelper @Inject constructor( Sources.TTDialog -> R.drawable.ic_temptarget_high Sources.ProfileSwitchDialog -> R.drawable.ic_actions_profileswitch Sources.LoopDialog -> R.drawable.ic_loop_closed - Sources.TempBasalDialog -> R.drawable.ic_actions_starttempbasal + Sources.TempBasalDialog -> R.drawable.ic_actions_start_temp_basal Sources.CalibrationDialog -> R.drawable.ic_calibration Sources.FillDialog -> R.drawable.ic_cp_pump_cannula Sources.BgCheck -> R.drawable.ic_cp_bgcheck diff --git a/core/core-main/src/main/res/drawable/ic_actions_starttempbasal.xml b/core/core-main/src/main/res/drawable/ic_actions_start_temp_basal.xml similarity index 100% rename from core/core-main/src/main/res/drawable/ic_actions_starttempbasal.xml rename to core/core-main/src/main/res/drawable/ic_actions_start_temp_basal.xml diff --git a/plugins/src/main/res/drawable/ic_clone_48.xml b/core/core-main/src/main/res/drawable/ic_clone_48.xml similarity index 100% rename from plugins/src/main/res/drawable/ic_clone_48.xml rename to core/core-main/src/main/res/drawable/ic_clone_48.xml diff --git a/app/src/main/res/drawable/ic_xdrip.xml b/core/core-main/src/main/res/drawable/ic_xdrip.xml similarity index 100% rename from app/src/main/res/drawable/ic_xdrip.xml rename to core/core-main/src/main/res/drawable/ic_xdrip.xml diff --git a/core/core-main/src/main/res/values/strings.xml b/core/core-main/src/main/res/values/strings.xml index 44e7460295..08cabe76d6 100644 --- a/core/core-main/src/main/res/values/strings.xml +++ b/core/core-main/src/main/res/values/strings.xml @@ -309,7 +309,7 @@ Start profile %1$d%% for %2$d min - Cancel temp basal + Cancel temp basal Let temp basal run Rate Duration @@ -335,7 +335,7 @@ Question : %1$s Exercise : %1$s Pump Site Change - CGM Sensor Insert + CGM Sensor Insert CGM Sensor Start CGM Sensor Stop D.A.D. Alert @@ -349,8 +349,8 @@ Temp Basal End Carbs correction OpenAPS Offline - Pump Battery Change - Temporary target + Pump Battery Change + Temporary target Temporary target value Temporary target cancel Bolus wizard diff --git a/core/core-main/src/test/java/info/nightscout/androidaps/data/PumpEnactResultTest.kt b/core/core-main/src/test/java/info/nightscout/androidaps/data/PumpEnactResultTest.kt index 8b79d49a37..3f21582a89 100644 --- a/core/core-main/src/test/java/info/nightscout/androidaps/data/PumpEnactResultTest.kt +++ b/core/core-main/src/test/java/info/nightscout/androidaps/data/PumpEnactResultTest.kt @@ -30,7 +30,7 @@ class PumpEnactResultTest : TestBaseWithProfile() { `when`(rh.gs(R.string.configbuilder_insulin)).thenReturn("Insulin") `when`(rh.gs(R.string.smb_shortname)).thenReturn("SMB") `when`(rh.gs(R.string.insulin_unit_shortname)).thenReturn("U") - `when`(rh.gs(R.string.canceltemp)).thenReturn("Cancel temp basal") + `when`(rh.gs(R.string.cancel_temp)).thenReturn("Cancel temp basal") `when`(rh.gs(R.string.duration)).thenReturn("Duration") `when`(rh.gs(R.string.percent)).thenReturn("Percent") `when`(rh.gs(R.string.absolute)).thenReturn("Absolute") diff --git a/interfaces/src/main/java/info/nightscout/interfaces/pump/Pump.kt b/interfaces/src/main/java/info/nightscout/interfaces/pump/Pump.kt index 7ab5ecebf6..fb49951e0e 100644 --- a/interfaces/src/main/java/info/nightscout/interfaces/pump/Pump.kt +++ b/interfaces/src/main/java/info/nightscout/interfaces/pump/Pump.kt @@ -284,4 +284,8 @@ interface Pump { * Pumps with a hardware link can set via config "Battery Change Logging" */ fun isBatteryChangeLoggingEnabled(): Boolean = false + /** + * Pumps is connect via RileyLink + */ + fun isUseRileyLinkBatteryLevel(): Boolean = false } diff --git a/interfaces/src/main/java/info/nightscout/interfaces/ui/ActivityNames.kt b/interfaces/src/main/java/info/nightscout/interfaces/ui/ActivityNames.kt index feac287d00..ef0b07c6b3 100644 --- a/interfaces/src/main/java/info/nightscout/interfaces/ui/ActivityNames.kt +++ b/interfaces/src/main/java/info/nightscout/interfaces/ui/ActivityNames.kt @@ -2,6 +2,7 @@ package info.nightscout.interfaces.ui import android.content.Context import androidx.annotation.RawRes +import androidx.annotation.StringRes import androidx.fragment.app.FragmentManager /** @@ -12,6 +13,7 @@ interface ActivityNames { val mainActivityClass: Class<*> val tddStatsActivity: Class<*> + val historyBrowseActivity: Class<*> val errorHelperActivity: Class<*> val bolusProgressHelperActivity: Class<*> val singleFragmentActivity: Class<*> @@ -25,7 +27,11 @@ interface ActivityNames { */ fun runAlarm(ctx: Context, status: String, title: String, @RawRes soundId: Int = 0) fun runWizard(fragmentManager: FragmentManager, carbs: Int, name: String) - fun runProfileSwitchDialog(fragmentManager: FragmentManager, profileName: String?) + fun runProfileSwitchDialog(fragmentManager: FragmentManager, profileName: String? = null) + fun runTempBasalDialog(fragmentManager: FragmentManager) + fun runTempTargetDialog(fragmentManager: FragmentManager) + fun runExtendedBolusDialog(fragmentManager: FragmentManager) + fun runFillDialog(fragmentManager: FragmentManager) enum class Mode(val i: Int) { RUNNING_PROFILE(1), @@ -34,4 +40,15 @@ interface ActivityNames { PROFILE_COMPARE(4) } fun runProfileViewerDialog(fragmentManager: FragmentManager, time: Long, mode: Mode, customProfile: String?= null, customProfileName: String? = null, customProfile2: String? = null) + enum class EventType { + BGCHECK, + SENSOR_INSERT, + BATTERY_CHANGE, + NOTE, + EXERCISE, + QUESTION, + ANNOUNCEMENT + } + + fun runCareDialog(fragmentManager: FragmentManager, options: EventType, @StringRes event: Int) } \ No newline at end of file diff --git a/plugins/build.gradle b/plugins/build.gradle index bb31fcebbe..c9433aab96 100644 --- a/plugins/build.gradle +++ b/plugins/build.gradle @@ -26,6 +26,9 @@ dependencies { implementation project(':interfaces') implementation project(':ns-sdk') + api "androidx.appcompat:appcompat:$appcompat_version" + api "com.google.android.material:material:$material_version" + // Actions api 'androidx.gridlayout:gridlayout:1.0.0' @@ -48,4 +51,6 @@ dependencies { api 'com.eatthepath:java-otp:0.3.1' api 'com.github.kenglxn.QRGen:android:2.6.0' + // Overview + api 'com.google.android.flexbox:flexbox:3.0.0' } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt b/plugins/src/main/java/info/nightscout/plugins/constraints/objectives/ObjectivesFragment.kt similarity index 96% rename from app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt rename to plugins/src/main/java/info/nightscout/plugins/constraints/objectives/ObjectivesFragment.kt index 8da858f9bd..d3e5657606 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt +++ b/plugins/src/main/java/info/nightscout/plugins/constraints/objectives/ObjectivesFragment.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.constraints.objectives +package info.nightscout.plugins.constraints.objectives import android.annotation.SuppressLint import android.os.Bundle @@ -16,26 +16,25 @@ import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearSmoothScroller import androidx.recyclerview.widget.RecyclerView import dagger.android.support.DaggerFragment -import info.nightscout.androidaps.R -import info.nightscout.androidaps.databinding.ObjectivesFragmentBinding -import info.nightscout.androidaps.databinding.ObjectivesItemBinding -import info.nightscout.androidaps.plugins.constraints.objectives.dialogs.NtpProgressDialog import info.nightscout.androidaps.logging.UserEntryLogger -import info.nightscout.androidaps.plugins.constraints.objectives.activities.ObjectivesExamDialog -import info.nightscout.androidaps.plugins.constraints.objectives.events.EventObjectivesUpdateGui -import info.nightscout.androidaps.plugins.constraints.objectives.objectives.Objective.ExamTask import info.nightscout.androidaps.receivers.ReceiverStatusStore -import info.nightscout.androidaps.setupwizard.events.EventSWUpdate -import info.nightscout.androidaps.utils.SntpClient import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.core.fabric.FabricPrivacy import info.nightscout.database.entities.UserEntry.Action import info.nightscout.database.entities.UserEntry.Sources import info.nightscout.database.entities.ValueWithUnit import info.nightscout.interfaces.utils.HtmlHelper +import info.nightscout.plugins.R +import info.nightscout.plugins.constraints.objectives.activities.ObjectivesExamDialog +import info.nightscout.plugins.constraints.objectives.dialogs.NtpProgressDialog +import info.nightscout.plugins.constraints.objectives.events.EventObjectivesUpdateGui +import info.nightscout.plugins.constraints.objectives.objectives.Objective.ExamTask +import info.nightscout.plugins.databinding.ObjectivesFragmentBinding +import info.nightscout.plugins.databinding.ObjectivesItemBinding import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.bus.RxBus import info.nightscout.rx.events.EventNtpStatus +import info.nightscout.rx.events.EventSWUpdate import info.nightscout.rx.logging.AAPSLogger import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.sharedPreferences.SP diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPlugin.kt b/plugins/src/main/java/info/nightscout/plugins/constraints/objectives/ObjectivesPlugin.kt similarity index 84% rename from app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPlugin.kt rename to plugins/src/main/java/info/nightscout/plugins/constraints/objectives/ObjectivesPlugin.kt index 922f3776eb..ef3948d528 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPlugin.kt +++ b/plugins/src/main/java/info/nightscout/plugins/constraints/objectives/ObjectivesPlugin.kt @@ -1,20 +1,8 @@ -package info.nightscout.androidaps.plugins.constraints.objectives +package info.nightscout.plugins.constraints.objectives import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.interfaces.Constraints -import info.nightscout.androidaps.plugins.constraints.objectives.objectives.Objective -import info.nightscout.androidaps.plugins.constraints.objectives.objectives.Objective0 -import info.nightscout.androidaps.plugins.constraints.objectives.objectives.Objective1 -import info.nightscout.androidaps.plugins.constraints.objectives.objectives.Objective10 -import info.nightscout.androidaps.plugins.constraints.objectives.objectives.Objective2 -import info.nightscout.androidaps.plugins.constraints.objectives.objectives.Objective3 -import info.nightscout.androidaps.plugins.constraints.objectives.objectives.Objective4 -import info.nightscout.androidaps.plugins.constraints.objectives.objectives.Objective5 -import info.nightscout.androidaps.plugins.constraints.objectives.objectives.Objective6 -import info.nightscout.androidaps.plugins.constraints.objectives.objectives.Objective7 -import info.nightscout.androidaps.plugins.constraints.objectives.objectives.Objective9 import info.nightscout.interfaces.Config import info.nightscout.interfaces.constraints.Constraint import info.nightscout.interfaces.constraints.Objectives @@ -27,6 +15,18 @@ import info.nightscout.interfaces.constraints.Objectives.Companion.SMB_OBJECTIVE import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginDescription import info.nightscout.interfaces.plugin.PluginType +import info.nightscout.plugins.R +import info.nightscout.plugins.constraints.objectives.objectives.Objective +import info.nightscout.plugins.constraints.objectives.objectives.Objective0 +import info.nightscout.plugins.constraints.objectives.objectives.Objective1 +import info.nightscout.plugins.constraints.objectives.objectives.Objective10 +import info.nightscout.plugins.constraints.objectives.objectives.Objective2 +import info.nightscout.plugins.constraints.objectives.objectives.Objective3 +import info.nightscout.plugins.constraints.objectives.objectives.Objective4 +import info.nightscout.plugins.constraints.objectives.objectives.Objective5 +import info.nightscout.plugins.constraints.objectives.objectives.Objective6 +import info.nightscout.plugins.constraints.objectives.objectives.Objective7 +import info.nightscout.plugins.constraints.objectives.objectives.Objective9 import info.nightscout.rx.logging.AAPSLogger import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.sharedPreferences.SP diff --git a/plugins/src/main/java/info/nightscout/plugins/constraints/objectives/SntpClient.kt b/plugins/src/main/java/info/nightscout/plugins/constraints/objectives/SntpClient.kt new file mode 100644 index 0000000000..47b8f4301d --- /dev/null +++ b/plugins/src/main/java/info/nightscout/plugins/constraints/objectives/SntpClient.kt @@ -0,0 +1,200 @@ +package info.nightscout.plugins.constraints.objectives + +import android.os.SystemClock +import info.nightscout.rx.logging.AAPSLogger +import info.nightscout.shared.utils.DateUtil +import java.net.DatagramPacket +import java.net.DatagramSocket +import java.net.InetAddress +import javax.inject.Inject +import javax.inject.Singleton + +/** +* {@hide} +* +* +* Simple SNTP client class for retrieving network time. +* +* +* Sample usage: +*
SntpClient client = new SntpClient();
+* if (client.requestTime("time.foo.com")) {
+* long now = client.getNtpTime() + SystemClock.elapsedRealtime() - client.getNtpTimeReference();
+* }
+
* +*/ +@Singleton +class SntpClient @Inject constructor( + private val aapsLogger: AAPSLogger, + private val dateUtil: DateUtil +) { + + companion object { + //private final int REFERENCE_TIME_OFFSET = 16; + private const val ORIGINATE_TIME_OFFSET = 24 + private const val RECEIVE_TIME_OFFSET = 32 + private const val TRANSMIT_TIME_OFFSET = 40 + private const val NTP_PACKET_SIZE = 48 + private const val NTP_PORT = 123 + private const val NTP_MODE_CLIENT = 3 + private const val NTP_VERSION = 3 + + // Number of seconds between Jan 1, 1900 and Jan 1, 1970 + // 70 years plus 17 leap days + private const val OFFSET_1900_TO_1970 = (365L * 70L + 17L) * 24L * 60L * 60L + } + + /** + * Returns the time computed from the NTP transaction. + * + * @return time value computed from NTP server response. + */ + // system time computed from NTP server response + private var ntpTime: Long = 0 + + /** + * Returns the reference clock value (value of SystemClock.elapsedRealtime()) + * corresponding to the NTP time. + * + * @return reference clock corresponding to the NTP time. + */ + // value of SystemClock.elapsedRealtime() corresponding to mNtpTime + private var ntpTimeReference: Long = 0 + + /** + * Returns the round trip time of the NTP transaction + * + * @return round trip time in milliseconds. + */ + // round trip time in milliseconds + private var roundTripTime: Long = 0 + + abstract class Callback : Runnable { + + var networkConnected = false + var success = false + var time: Long = 0 + } + + @Synchronized fun ntpTime(callback: Callback, isConnected: Boolean) { + callback.networkConnected = isConnected + if (callback.networkConnected) { + Thread { doNtpTime(callback) }.start() + } else { + callback.run() + } + } + + fun doNtpTime(callback: Callback) { + aapsLogger.debug("Time detection started") + callback.success = requestTime("time.google.com", 5000) + callback.time = ntpTime + SystemClock.elapsedRealtime() - ntpTimeReference + aapsLogger.debug("Time detection ended: " + callback.success + " " + dateUtil.dateAndTimeString(ntpTime)) + callback.run() + } + + /** + * Sends an SNTP request to the given host and processes the response. + * + * @param host host name of the server. + * @param timeout network timeout in milliseconds. + * @return true if the transaction was successful. + */ + @Suppress("SameParameterValue") + @Synchronized private fun requestTime(host: String, timeout: Int): Boolean { + try { + val socket = DatagramSocket() + socket.soTimeout = timeout + val address = InetAddress.getByName(host) + val buffer = ByteArray(NTP_PACKET_SIZE) + val request = DatagramPacket(buffer, buffer.size, address, NTP_PORT) + + // set mode = 3 (client) and version = 3 + // mode is in low 3 bits of first byte + // version is in bits 3-5 of first byte + buffer[0] = (NTP_MODE_CLIENT or (NTP_VERSION shl 3)).toByte() + + // get current time and write it to the request packet + val requestTime = System.currentTimeMillis() + val requestTicks = SystemClock.elapsedRealtime() + writeTimeStamp(buffer, TRANSMIT_TIME_OFFSET, requestTime) + socket.send(request) + + // read the response + val response = DatagramPacket(buffer, buffer.size) + socket.receive(response) + val responseTicks = SystemClock.elapsedRealtime() + val responseTime = requestTime + (responseTicks - requestTicks) + socket.close() + + // extract the results + val originateTime = readTimeStamp(buffer, ORIGINATE_TIME_OFFSET) + val receiveTime = readTimeStamp(buffer, RECEIVE_TIME_OFFSET) + val transmitTime = readTimeStamp(buffer, TRANSMIT_TIME_OFFSET) + val roundTripTime = responseTicks - requestTicks - (transmitTime - receiveTime) + val clockOffset = (receiveTime - originateTime + (transmitTime - responseTime)) / 2 + + // save our results - use the times on this side of the network latency + // (response rather than request time) + ntpTime = responseTime + clockOffset + ntpTimeReference = responseTicks + this.roundTripTime = roundTripTime + } catch (e: Exception) { + aapsLogger.debug("request time failed: $e") + return false + } + return true + } + + /** + * Reads an unsigned 32 bit big endian number from the given offset in the buffer. + */ + private fun read32(buffer: ByteArray, offset: Int): Long { + val b0 = buffer[offset] + val b1 = buffer[offset + 1] + val b2 = buffer[offset + 2] + val b3 = buffer[offset + 3] + + // convert signed bytes to unsigned values + val i0 = if (b0.toInt() and 0x80 == 0x80) (b0.toInt() and 0x7F) + 0x80 else b0.toInt() + val i1 = if (b1.toInt() and 0x80 == 0x80) (b1.toInt() and 0x7F) + 0x80 else b1.toInt() + val i2 = if (b2.toInt() and 0x80 == 0x80) (b2.toInt() and 0x7F) + 0x80 else b2.toInt() + val i3 = if (b3.toInt() and 0x80 == 0x80) (b3.toInt() and 0x7F) + 0x80 else b3.toInt() + return (i0.toLong() shl 24) + (i1.toLong() shl 16) + (i2.toLong() shl 8) + i3.toLong() + } + + /** + * Reads the NTP time stamp at the given offset in the buffer and returns + * it as a system time (milliseconds since January 1, 1970). + */ + private fun readTimeStamp(buffer: ByteArray, offset: Int): Long { + val seconds = read32(buffer, offset) + val fraction = read32(buffer, offset + 4) + return (seconds - OFFSET_1900_TO_1970) * 1000 + fraction * 1000L / 0x100000000L + } + + /** + * Writes system time (milliseconds since January 1, 1970) as an NTP time stamp + * at the given offset in the buffer. + */ + @Suppress("SameParameterValue") + private fun writeTimeStamp(buffer: ByteArray, offsetParam: Int, time: Long) { + var offset = offsetParam + var seconds = time / 1000L + val milliseconds = time - seconds * 1000L + seconds += OFFSET_1900_TO_1970 + + // write seconds in big endian format + buffer[offset++] = (seconds shr 24).toByte() + buffer[offset++] = (seconds shr 16).toByte() + buffer[offset++] = (seconds shr 8).toByte() + buffer[offset++] = (seconds shr 0).toByte() + val fraction = milliseconds * 0x100000000L / 1000L + // write fraction in big endian format + buffer[offset++] = (fraction shr 24).toByte() + buffer[offset++] = (fraction shr 16).toByte() + buffer[offset++] = (fraction shr 8).toByte() + // low order bits should be random data + buffer[offset] = (Math.random() * 255.0).toInt().toByte() + } +} \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/activities/ObjectivesExamDialog.kt b/plugins/src/main/java/info/nightscout/plugins/constraints/objectives/activities/ObjectivesExamDialog.kt similarity index 88% rename from app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/activities/ObjectivesExamDialog.kt rename to plugins/src/main/java/info/nightscout/plugins/constraints/objectives/activities/ObjectivesExamDialog.kt index fc917ae093..89ba9b17c3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/activities/ObjectivesExamDialog.kt +++ b/plugins/src/main/java/info/nightscout/plugins/constraints/objectives/activities/ObjectivesExamDialog.kt @@ -1,21 +1,21 @@ -package info.nightscout.androidaps.plugins.constraints.objectives.activities +package info.nightscout.plugins.constraints.objectives.activities import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import dagger.android.support.DaggerDialogFragment -import info.nightscout.androidaps.R -import info.nightscout.androidaps.databinding.ObjectivesExamFragmentBinding +import info.nightscout.androidaps.utils.ToastUtils +import info.nightscout.plugins.R +import info.nightscout.plugins.constraints.objectives.events.EventObjectivesUpdateGui +import info.nightscout.plugins.constraints.objectives.objectives.Objective +import info.nightscout.plugins.constraints.objectives.objectives.Objective.ExamTask +import info.nightscout.plugins.constraints.objectives.objectives.Objective.Option +import info.nightscout.plugins.databinding.ObjectivesExamFragmentBinding +import info.nightscout.rx.bus.RxBus import info.nightscout.shared.interfaces.ResourceHelper -import info.nightscout.androidaps.plugins.constraints.objectives.events.EventObjectivesUpdateGui -import info.nightscout.androidaps.plugins.constraints.objectives.objectives.Objective -import info.nightscout.androidaps.plugins.constraints.objectives.objectives.Objective.ExamTask -import info.nightscout.androidaps.plugins.constraints.objectives.objectives.Objective.Option import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.T -import info.nightscout.androidaps.utils.ToastUtils -import info.nightscout.rx.bus.RxBus import javax.inject.Inject class ObjectivesExamDialog : DaggerDialogFragment() { @@ -96,8 +96,8 @@ class ObjectivesExamDialog : DaggerDialogFragment() { context?.let { binding.examHints.addView(h.generate(it)) } } // Disabled to - binding.examDisabledto.text = rh.gs(R.string.answerdisabledto, dateUtil.timeString(task.disabledTo)) - binding.examDisabledto.visibility = if (task.isEnabledAnswer()) View.GONE else View.VISIBLE + binding.examDisabledTo.text = rh.gs(R.string.answerdisabledto, dateUtil.timeString(task.disabledTo)) + binding.examDisabledTo.visibility = if (task.isEnabledAnswer()) View.GONE else View.VISIBLE // Buttons binding.examVerify.isEnabled = !task.answered && task.isEnabledAnswer() binding.examVerify.setOnClickListener { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/dialogs/NtpProgressDialog.kt b/plugins/src/main/java/info/nightscout/plugins/constraints/objectives/dialogs/NtpProgressDialog.kt similarity index 98% rename from app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/dialogs/NtpProgressDialog.kt rename to plugins/src/main/java/info/nightscout/plugins/constraints/objectives/dialogs/NtpProgressDialog.kt index 7a10ec9a5b..a4adb728d1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/dialogs/NtpProgressDialog.kt +++ b/plugins/src/main/java/info/nightscout/plugins/constraints/objectives/dialogs/NtpProgressDialog.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.constraints.objectives.dialogs +package info.nightscout.plugins.constraints.objectives.dialogs import android.os.Bundle import android.os.SystemClock diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/events/EventObjectivesUpdateGui.kt b/plugins/src/main/java/info/nightscout/plugins/constraints/objectives/events/EventObjectivesUpdateGui.kt similarity index 57% rename from app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/events/EventObjectivesUpdateGui.kt rename to plugins/src/main/java/info/nightscout/plugins/constraints/objectives/events/EventObjectivesUpdateGui.kt index d5acd670f1..208d11625e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/events/EventObjectivesUpdateGui.kt +++ b/plugins/src/main/java/info/nightscout/plugins/constraints/objectives/events/EventObjectivesUpdateGui.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.constraints.objectives.events +package info.nightscout.plugins.constraints.objectives.events import info.nightscout.rx.events.EventUpdateGui diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective.kt b/plugins/src/main/java/info/nightscout/plugins/constraints/objectives/objectives/Objective.kt similarity index 98% rename from app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective.kt rename to plugins/src/main/java/info/nightscout/plugins/constraints/objectives/objectives/Objective.kt index c30bdf7fe0..e793998f55 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective.kt +++ b/plugins/src/main/java/info/nightscout/plugins/constraints/objectives/objectives/Objective.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.constraints.objectives.objectives +package info.nightscout.plugins.constraints.objectives.objectives import android.content.Context import android.text.util.Linkify @@ -7,7 +7,7 @@ import android.widget.TextView import androidx.annotation.StringRes import androidx.fragment.app.FragmentActivity import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.plugins.R import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.utils.DateUtil diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective0.kt b/plugins/src/main/java/info/nightscout/plugins/constraints/objectives/objectives/Objective0.kt similarity index 96% rename from app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective0.kt rename to plugins/src/main/java/info/nightscout/plugins/constraints/objectives/objectives/Objective0.kt index 7dc1002b3e..3c0c31a567 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective0.kt +++ b/plugins/src/main/java/info/nightscout/plugins/constraints/objectives/objectives/Objective0.kt @@ -1,13 +1,13 @@ -package info.nightscout.androidaps.plugins.constraints.objectives.objectives +package info.nightscout.plugins.constraints.objectives.objectives import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.interfaces.IobCobCalculator import info.nightscout.androidaps.interfaces.Loop import info.nightscout.database.impl.AppRepository import info.nightscout.database.impl.ValueWrapper import info.nightscout.interfaces.plugin.PluginBase +import info.nightscout.plugins.R import info.nightscout.plugins.pump.virtual.VirtualPumpPlugin import javax.inject.Inject diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective1.kt b/plugins/src/main/java/info/nightscout/plugins/constraints/objectives/objectives/Objective1.kt similarity index 92% rename from app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective1.kt rename to plugins/src/main/java/info/nightscout/plugins/constraints/objectives/objectives/Objective1.kt index 8a3abb5817..bd8955c824 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective1.kt +++ b/plugins/src/main/java/info/nightscout/plugins/constraints/objectives/objectives/Objective1.kt @@ -1,8 +1,8 @@ -package info.nightscout.androidaps.plugins.constraints.objectives.objectives +package info.nightscout.plugins.constraints.objectives.objectives import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R -import info.nightscout.androidaps.plugins.general.actions.ActionsPlugin +import info.nightscout.plugins.R +import info.nightscout.plugins.general.actions.ActionsPlugin import javax.inject.Inject class Objective1 @Inject constructor(injector: HasAndroidInjector) : Objective(injector, "usage", R.string.objectives_usage_objective, R.string.objectives_usage_gate) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective10.kt b/plugins/src/main/java/info/nightscout/plugins/constraints/objectives/objectives/Objective10.kt similarity index 73% rename from app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective10.kt rename to plugins/src/main/java/info/nightscout/plugins/constraints/objectives/objectives/Objective10.kt index efbbc91a97..45e9375d78 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective10.kt +++ b/plugins/src/main/java/info/nightscout/plugins/constraints/objectives/objectives/Objective10.kt @@ -1,7 +1,7 @@ -package info.nightscout.androidaps.plugins.constraints.objectives.objectives +package info.nightscout.plugins.constraints.objectives.objectives import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.plugins.R import info.nightscout.shared.utils.T class Objective10(injector: HasAndroidInjector) : Objective(injector, "auto", R.string.objectives_auto_objective, R.string.objectives_auto_gate) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective2.kt b/plugins/src/main/java/info/nightscout/plugins/constraints/objectives/objectives/Objective2.kt similarity index 98% rename from app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective2.kt rename to plugins/src/main/java/info/nightscout/plugins/constraints/objectives/objectives/Objective2.kt index 4c79036f9b..3e598c6ba5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective2.kt +++ b/plugins/src/main/java/info/nightscout/plugins/constraints/objectives/objectives/Objective2.kt @@ -1,7 +1,7 @@ -package info.nightscout.androidaps.plugins.constraints.objectives.objectives +package info.nightscout.plugins.constraints.objectives.objectives import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.plugins.R @Suppress("SpellCheckingInspection") class Objective2(injector: HasAndroidInjector) : Objective(injector, "exam", R.string.objectives_exam_objective, R.string.objectives_exam_gate) { @@ -113,7 +113,7 @@ class Objective2(injector: HasAndroidInjector) : Objective(injector, "exam", R.s .option(Option(R.string.pumpdisconnect_openloop, false)) .hint(Hint(R.string.pumpdisconnect_hint1)) ) - tasks.add(ExamTask(this, R.string.insulin_label, R.string.insulin_ultrarapid, "insulin") + tasks.add(ExamTask(this, R.string.insulin_plugins, R.string.insulin_ultrarapid, "insulin") .option(Option(R.string.insulin_novorapid, false)) .option(Option(R.string.insulin_humalog, false)) .option(Option(R.string.insulin_actrapid, false)) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective3.kt b/plugins/src/main/java/info/nightscout/plugins/constraints/objectives/objectives/Objective3.kt similarity index 91% rename from app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective3.kt rename to plugins/src/main/java/info/nightscout/plugins/constraints/objectives/objectives/Objective3.kt index 36d6dc1e2b..342623d32b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective3.kt +++ b/plugins/src/main/java/info/nightscout/plugins/constraints/objectives/objectives/Objective3.kt @@ -1,8 +1,8 @@ -package info.nightscout.androidaps.plugins.constraints.objectives.objectives +package info.nightscout.plugins.constraints.objectives.objectives import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R import info.nightscout.androidaps.interfaces.ActivePlugin +import info.nightscout.plugins.R import info.nightscout.shared.utils.T import javax.inject.Inject diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective4.kt b/plugins/src/main/java/info/nightscout/plugins/constraints/objectives/objectives/Objective4.kt similarity index 67% rename from app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective4.kt rename to plugins/src/main/java/info/nightscout/plugins/constraints/objectives/objectives/Objective4.kt index 6ba5721ca8..1871038194 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective4.kt +++ b/plugins/src/main/java/info/nightscout/plugins/constraints/objectives/objectives/Objective4.kt @@ -1,7 +1,7 @@ -package info.nightscout.androidaps.plugins.constraints.objectives.objectives +package info.nightscout.plugins.constraints.objectives.objectives import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.plugins.R @Suppress("SpellCheckingInspection") class Objective4(injector: HasAndroidInjector) : Objective(injector, "maxbasal", R.string.objectives_maxbasal_objective, R.string.objectives_maxbasal_gate) \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective5.kt b/plugins/src/main/java/info/nightscout/plugins/constraints/objectives/objectives/Objective5.kt similarity index 81% rename from app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective5.kt rename to plugins/src/main/java/info/nightscout/plugins/constraints/objectives/objectives/Objective5.kt index cbbc6f1467..35b5024cc0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective5.kt +++ b/plugins/src/main/java/info/nightscout/plugins/constraints/objectives/objectives/Objective5.kt @@ -1,9 +1,9 @@ -package info.nightscout.androidaps.plugins.constraints.objectives.objectives +package info.nightscout.plugins.constraints.objectives.objectives import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R -import info.nightscout.androidaps.plugins.constraints.safety.SafetyPlugin import info.nightscout.interfaces.constraints.Constraint +import info.nightscout.plugins.R +import info.nightscout.plugins.constraints.safety.SafetyPlugin import info.nightscout.shared.utils.T import javax.inject.Inject diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective6.kt b/plugins/src/main/java/info/nightscout/plugins/constraints/objectives/objectives/Objective6.kt similarity index 80% rename from app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective6.kt rename to plugins/src/main/java/info/nightscout/plugins/constraints/objectives/objectives/Objective6.kt index 2999b02c49..4eca10cdc8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective6.kt +++ b/plugins/src/main/java/info/nightscout/plugins/constraints/objectives/objectives/Objective6.kt @@ -1,9 +1,8 @@ -package info.nightscout.androidaps.plugins.constraints.objectives.objectives +package info.nightscout.plugins.constraints.objectives.objectives import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R import info.nightscout.androidaps.interfaces.Constraints -import info.nightscout.androidaps.plugins.constraints.safety.SafetyPlugin +import info.nightscout.plugins.R import info.nightscout.shared.utils.T import javax.inject.Inject @@ -11,7 +10,6 @@ import javax.inject.Inject class Objective6(injector: HasAndroidInjector) : Objective(injector, "maxiob", R.string.objectives_maxiob_objective, R.string.objectives_maxiob_gate) { @Inject lateinit var constraintChecker: Constraints - @Inject lateinit var safetyPlugin: SafetyPlugin init { tasks.add(MinimumDurationTask(this, T.days(1).msecs())) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective7.kt b/plugins/src/main/java/info/nightscout/plugins/constraints/objectives/objectives/Objective7.kt similarity index 74% rename from app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective7.kt rename to plugins/src/main/java/info/nightscout/plugins/constraints/objectives/objectives/Objective7.kt index 57698d2fcb..4ace165453 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective7.kt +++ b/plugins/src/main/java/info/nightscout/plugins/constraints/objectives/objectives/Objective7.kt @@ -1,7 +1,7 @@ -package info.nightscout.androidaps.plugins.constraints.objectives.objectives +package info.nightscout.plugins.constraints.objectives.objectives import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.plugins.R import info.nightscout.shared.utils.T class Objective7(injector: HasAndroidInjector) : Objective(injector, "autosens", R.string.objectives_autosens_objective, R.string.objectives_autosens_gate) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective9.kt b/plugins/src/main/java/info/nightscout/plugins/constraints/objectives/objectives/Objective9.kt similarity index 73% rename from app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective9.kt rename to plugins/src/main/java/info/nightscout/plugins/constraints/objectives/objectives/Objective9.kt index 9ea48b4bf9..3031f9d283 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective9.kt +++ b/plugins/src/main/java/info/nightscout/plugins/constraints/objectives/objectives/Objective9.kt @@ -1,7 +1,7 @@ -package info.nightscout.androidaps.plugins.constraints.objectives.objectives +package info.nightscout.plugins.constraints.objectives.objectives import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R +import info.nightscout.plugins.R import info.nightscout.shared.utils.T class Objective9(injector: HasAndroidInjector) : Objective(injector, "smb", R.string.objectives_smb_objective, R.string.objectives_smb_gate) { diff --git a/plugins/src/main/java/info/nightscout/plugins/constraints/objectives/objectives/SntpClient.kt b/plugins/src/main/java/info/nightscout/plugins/constraints/objectives/objectives/SntpClient.kt new file mode 100644 index 0000000000..635720be75 --- /dev/null +++ b/plugins/src/main/java/info/nightscout/plugins/constraints/objectives/objectives/SntpClient.kt @@ -0,0 +1,2 @@ +package info.nightscout.plugins.constraints.objectives.objectives + diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPlugin.kt b/plugins/src/main/java/info/nightscout/plugins/constraints/safety/SafetyPlugin.kt similarity index 87% rename from app/src/main/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPlugin.kt rename to plugins/src/main/java/info/nightscout/plugins/constraints/safety/SafetyPlugin.kt index 771bf8c230..da6afdda5b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPlugin.kt +++ b/plugins/src/main/java/info/nightscout/plugins/constraints/safety/SafetyPlugin.kt @@ -1,7 +1,6 @@ -package info.nightscout.androidaps.plugins.constraints.safety +package info.nightscout.plugins.constraints.safety import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R import info.nightscout.androidaps.extensions.putDouble import info.nightscout.androidaps.extensions.putInt import info.nightscout.androidaps.extensions.putString @@ -11,11 +10,7 @@ import info.nightscout.androidaps.extensions.storeString import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.interfaces.Constraints import info.nightscout.androidaps.interfaces.IobCobCalculator -import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin -import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin -import info.nightscout.androidaps.plugins.aps.openAPSSMBDynamicISF.OpenAPSSMBDynamicISFPlugin import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification -import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin import info.nightscout.androidaps.utils.DecimalFormatter import info.nightscout.interfaces.BuildHelper import info.nightscout.interfaces.Config @@ -29,6 +24,7 @@ import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.pump.defs.PumpDescription import info.nightscout.interfaces.utils.HardLimits import info.nightscout.interfaces.utils.Round +import info.nightscout.plugins.R import info.nightscout.rx.bus.RxBus import info.nightscout.rx.logging.AAPSLogger import info.nightscout.shared.interfaces.ResourceHelper @@ -47,10 +43,6 @@ class SafetyPlugin @Inject constructor( private val sp: SP, private val rxBus: RxBus, private val constraintChecker: Constraints, - private val openAPSAMAPlugin: OpenAPSAMAPlugin, - private val openAPSSMBPlugin: OpenAPSSMBPlugin, - private val openAPSSMBDynamicISFPlugin: OpenAPSSMBDynamicISFPlugin, - private val sensitivityOref1Plugin: SensitivityOref1Plugin, private val activePlugin: ActivePlugin, private val hardLimits: HardLimits, private val buildHelper: BuildHelper, @@ -110,8 +102,6 @@ class SafetyPlugin @Inject constructor( override fun isUAMEnabled(value: Constraint): Constraint { val enabled = sp.getBoolean(R.string.key_use_uam, false) if (!enabled) value.set(aapsLogger, false, rh.gs(R.string.uamdisabledinpreferences), this) - val oref1Enabled = sensitivityOref1Plugin.isEnabled() - if (!oref1Enabled) value.set(aapsLogger, false, rh.gs(R.string.uamdisabledoref1notselected), this) return value } @@ -203,12 +193,6 @@ class SafetyPlugin @Inject constructor( override fun applyMaxIOBConstraints(maxIob: Constraint): Constraint { val apsMode = sp.getString(R.string.key_aps_mode, "open") - val maxIobPref: Double = if (openAPSSMBPlugin.isEnabled() || openAPSSMBDynamicISFPlugin.isEnabled()) sp.getDouble(R.string.key_openapssmb_max_iob, 3.0) else sp.getDouble(R.string - .key_openapsma_max_iob, 1.5) - maxIob.setIfSmaller(aapsLogger, maxIobPref, rh.gs(R.string.limitingiob, maxIobPref, rh.gs(R.string.maxvalueinpreferences)), this) - if (openAPSAMAPlugin.isEnabled()) maxIob.setIfSmaller(aapsLogger, hardLimits.maxIobAMA(), rh.gs(R.string.limitingiob, hardLimits.maxIobAMA(), rh.gs(R.string.hardlimit)), this) - if (openAPSSMBPlugin.isEnabled()) maxIob.setIfSmaller(aapsLogger, hardLimits.maxIobSMB(), rh.gs(R.string.limitingiob, hardLimits.maxIobSMB(), rh.gs(R.string.hardlimit)), this) - if (openAPSSMBDynamicISFPlugin.isEnabled()) maxIob.setIfSmaller(aapsLogger, hardLimits.maxIobSMB(), rh.gs(R.string.limitingiob, hardLimits.maxIobSMB(), rh.gs(R.string.hardlimit)), this) if (apsMode == "lgs") maxIob.setIfSmaller(aapsLogger, HardLimits.MAX_IOB_LGS, rh.gs(R.string.limitingiob, HardLimits.MAX_IOB_LGS, rh.gs(R.string.lowglucosesuspend)), this) return maxIob } diff --git a/plugins/src/main/java/info/nightscout/plugins/di/ObjectivesModule.kt b/plugins/src/main/java/info/nightscout/plugins/di/ObjectivesModule.kt new file mode 100644 index 0000000000..b9c9943ebf --- /dev/null +++ b/plugins/src/main/java/info/nightscout/plugins/di/ObjectivesModule.kt @@ -0,0 +1,33 @@ +package info.nightscout.plugins.di + +import dagger.Module +import dagger.android.ContributesAndroidInjector +import info.nightscout.plugins.constraints.objectives.objectives.Objective +import info.nightscout.plugins.constraints.objectives.objectives.Objective0 +import info.nightscout.plugins.constraints.objectives.objectives.Objective1 +import info.nightscout.plugins.constraints.objectives.objectives.Objective10 +import info.nightscout.plugins.constraints.objectives.objectives.Objective2 +import info.nightscout.plugins.constraints.objectives.objectives.Objective3 +import info.nightscout.plugins.constraints.objectives.objectives.Objective4 +import info.nightscout.plugins.constraints.objectives.objectives.Objective5 +import info.nightscout.plugins.constraints.objectives.objectives.Objective6 +import info.nightscout.plugins.constraints.objectives.objectives.Objective7 +import info.nightscout.plugins.constraints.objectives.objectives.Objective9 + +@Module +@Suppress("unused") +abstract class ObjectivesModule { + + @ContributesAndroidInjector abstract fun objectiveInjector(): Objective + @ContributesAndroidInjector abstract fun objective0Injector(): Objective0 + @ContributesAndroidInjector abstract fun objective1Injector(): Objective1 + @ContributesAndroidInjector abstract fun objective2Injector(): Objective2 + @ContributesAndroidInjector abstract fun objective3Injector(): Objective3 + @ContributesAndroidInjector abstract fun objective4Injector(): Objective4 + @ContributesAndroidInjector abstract fun objective5Injector(): Objective5 + @ContributesAndroidInjector abstract fun objective6Injector(): Objective6 + @ContributesAndroidInjector abstract fun objective7Injector(): Objective7 + @ContributesAndroidInjector abstract fun objective9Injector(): Objective9 + @ContributesAndroidInjector abstract fun objective10Injector(): Objective10 + +} \ No newline at end of file diff --git a/plugins/src/main/java/info/nightscout/plugins/di/PluginsModule.kt b/plugins/src/main/java/info/nightscout/plugins/di/PluginsModule.kt index 57c9aae6e7..e461798ffd 100644 --- a/plugins/src/main/java/info/nightscout/plugins/di/PluginsModule.kt +++ b/plugins/src/main/java/info/nightscout/plugins/di/PluginsModule.kt @@ -11,7 +11,9 @@ import dagger.Module ProfileModule::class, SyncModule::class, SourceModule::class, - VirtualPumpModule::class + VirtualPumpModule::class, + ObjectivesModule::class, + SkinsModule::class ] ) diff --git a/app/src/main/java/info/nightscout/androidaps/di/SkinsModule.kt b/plugins/src/main/java/info/nightscout/plugins/di/SkinsModule.kt similarity index 71% rename from app/src/main/java/info/nightscout/androidaps/di/SkinsModule.kt rename to plugins/src/main/java/info/nightscout/plugins/di/SkinsModule.kt index cd450e653b..b92946e32b 100644 --- a/app/src/main/java/info/nightscout/androidaps/di/SkinsModule.kt +++ b/plugins/src/main/java/info/nightscout/plugins/di/SkinsModule.kt @@ -1,14 +1,14 @@ -package info.nightscout.androidaps.di +package info.nightscout.plugins.di import dagger.Module import dagger.Provides import dagger.multibindings.IntKey import dagger.multibindings.IntoMap -import info.nightscout.androidaps.skins.SkinButtonsOn -import info.nightscout.androidaps.skins.SkinClassic -import info.nightscout.androidaps.skins.SkinInterface -import info.nightscout.androidaps.skins.SkinLargeDisplay -import info.nightscout.androidaps.skins.SkinLowRes +import info.nightscout.plugins.skins.SkinButtonsOn +import info.nightscout.plugins.skins.SkinClassic +import info.nightscout.plugins.skins.SkinInterface +import info.nightscout.plugins.skins.SkinLargeDisplay +import info.nightscout.plugins.skins.SkinLowRes import javax.inject.Qualifier @Module diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt b/plugins/src/main/java/info/nightscout/plugins/general/actions/ActionsFragment.kt similarity index 86% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt rename to plugins/src/main/java/info/nightscout/plugins/general/actions/ActionsFragment.kt index 9ef92c6d1b..0e40fd2c2f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt +++ b/plugins/src/main/java/info/nightscout/plugins/general/actions/ActionsFragment.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.general.actions +package info.nightscout.plugins.general.actions import android.content.Context import android.content.Intent @@ -10,12 +10,6 @@ import android.view.ViewGroup import android.widget.LinearLayout import androidx.core.content.ContextCompat import dagger.android.support.DaggerFragment -import info.nightscout.androidaps.R -import info.nightscout.androidaps.activities.HistoryBrowseActivity -import info.nightscout.androidaps.databinding.ActionsFragmentBinding -import info.nightscout.ui.dialogs.ProfileSwitchDialog -import info.nightscout.ui.dialogs.TempBasalDialog -import info.nightscout.ui.dialogs.TempTargetDialog import info.nightscout.androidaps.extensions.toStringMedium import info.nightscout.androidaps.extensions.toStringShort import info.nightscout.androidaps.interfaces.ActivePlugin @@ -24,8 +18,6 @@ import info.nightscout.androidaps.interfaces.IobCobCalculator import info.nightscout.androidaps.interfaces.Loop import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.logging.UserEntryLogger -import info.nightscout.androidaps.plugins.general.overview.StatusLightHandler -import info.nightscout.androidaps.skins.SkinProvider import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.androidaps.utils.protection.ProtectionCheck import info.nightscout.androidaps.utils.ui.SingleClickButton @@ -40,6 +32,10 @@ import info.nightscout.interfaces.Config import info.nightscout.interfaces.pump.actions.CustomAction import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.ui.ActivityNames +import info.nightscout.plugins.R +import info.nightscout.plugins.databinding.ActionsFragmentBinding +import info.nightscout.plugins.skins.SkinProvider +import info.nightscout.plugins.ui.StatusLightHandler import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.bus.RxBus import info.nightscout.rx.events.EventCustomActionsChanged @@ -52,10 +48,6 @@ import info.nightscout.shared.extensions.toVisibility import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.utils.DateUtil -import info.nightscout.ui.activities.TDDStatsActivity -import info.nightscout.ui.dialogs.CareDialog -import info.nightscout.ui.dialogs.ExtendedBolusDialog -import info.nightscout.ui.dialogs.FillDialog import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.kotlin.plusAssign import javax.inject.Inject @@ -91,6 +83,7 @@ class ActionsFragment : DaggerFragment() { private lateinit var dm: DisplayMetrics private var _binding: ActionsFragmentBinding? = null + // This property is only valid between onCreateView and onDestroyView. private val binding get() = _binding!! @@ -105,7 +98,7 @@ class ActionsFragment : DaggerFragment() { activity?.windowManager?.defaultDisplay?.getMetrics(dm) } _binding = ActionsFragmentBinding.inflate(inflater, container, false) - return binding.root + return binding.root } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { @@ -118,7 +111,7 @@ class ActionsFragment : DaggerFragment() { protectionCheck.queryProtection( activity, ProtectionCheck.Protection.BOLUS, - UIRunnable { ProfileSwitchDialog().show(childFragmentManager, "ProfileSwitchDialog")}) + UIRunnable { activityNames.runProfileSwitchDialog(childFragmentManager) }) } } binding.tempTarget.setOnClickListener { @@ -126,7 +119,7 @@ class ActionsFragment : DaggerFragment() { protectionCheck.queryProtection( activity, ProtectionCheck.Protection.BOLUS, - UIRunnable { TempTargetDialog().show(childFragmentManager, "Actions") }) + UIRunnable { activityNames.runTempTargetDialog(childFragmentManager) }) } } binding.extendedBolus.setOnClickListener { @@ -135,7 +128,7 @@ class ActionsFragment : DaggerFragment() { OKDialog.showConfirmation( activity, rh.gs(R.string.extended_bolus), rh.gs(R.string.ebstopsloop), Runnable { - ExtendedBolusDialog().show(childFragmentManager, "Actions") + activityNames.runExtendedBolusDialog(childFragmentManager) }, null ) }) @@ -158,7 +151,7 @@ class ActionsFragment : DaggerFragment() { protectionCheck.queryProtection( activity, ProtectionCheck.Protection.BOLUS, - UIRunnable { TempBasalDialog().show(childFragmentManager, "Actions") }) + UIRunnable { activityNames.runTempBasalDialog(childFragmentManager) }) } } binding.cancelTempBasal.setOnClickListener { @@ -175,31 +168,31 @@ class ActionsFragment : DaggerFragment() { } binding.fill.setOnClickListener { activity?.let { activity -> - protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { FillDialog().show(childFragmentManager, "FillDialog") }) + protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { activityNames.runFillDialog(childFragmentManager) }) } } - binding.historyBrowser.setOnClickListener { startActivity(Intent(context, HistoryBrowseActivity::class.java)) } - binding.tddStats.setOnClickListener { startActivity(Intent(context, TDDStatsActivity::class.java)) } + binding.historyBrowser.setOnClickListener { startActivity(Intent(context, activityNames.historyBrowseActivity::class.java)) } + binding.tddStats.setOnClickListener { startActivity(Intent(context, activityNames.tddStatsActivity::class.java)) } binding.bgCheck.setOnClickListener { - CareDialog().setOptions(CareDialog.EventType.BGCHECK, R.string.careportal_bgcheck).show(childFragmentManager, "Actions") + activityNames.runCareDialog(childFragmentManager, ActivityNames.EventType.BGCHECK, R.string.careportal_bgcheck) } binding.cgmSensorInsert.setOnClickListener { - CareDialog().setOptions(CareDialog.EventType.SENSOR_INSERT, R.string.careportal_cgmsensorinsert).show(childFragmentManager, "Actions") + activityNames.runCareDialog(childFragmentManager, ActivityNames.EventType.SENSOR_INSERT, R.string.cgm_sensor_insert) } binding.pumpBatteryChange.setOnClickListener { - CareDialog().setOptions(CareDialog.EventType.BATTERY_CHANGE, R.string.careportal_pumpbatterychange).show(childFragmentManager, "Actions") + activityNames.runCareDialog(childFragmentManager, ActivityNames.EventType.BATTERY_CHANGE, R.string.pump_battery_change) } binding.note.setOnClickListener { - CareDialog().setOptions(CareDialog.EventType.NOTE, R.string.careportal_note).show(childFragmentManager, "Actions") + activityNames.runCareDialog(childFragmentManager, ActivityNames.EventType.NOTE, R.string.careportal_note) } binding.exercise.setOnClickListener { - CareDialog().setOptions(CareDialog.EventType.EXERCISE, R.string.careportal_exercise).show(childFragmentManager, "Actions") + activityNames.runCareDialog(childFragmentManager, ActivityNames.EventType.EXERCISE, R.string.careportal_exercise) } binding.question.setOnClickListener { - CareDialog().setOptions(CareDialog.EventType.QUESTION, R.string.careportal_question).show(childFragmentManager, "Actions") + activityNames.runCareDialog(childFragmentManager, ActivityNames.EventType.QUESTION, R.string.careportal_question) } binding.announcement.setOnClickListener { - CareDialog().setOptions(CareDialog.EventType.ANNOUNCEMENT, R.string.careportal_announcement).show(childFragmentManager, "Actions") + activityNames.runCareDialog(childFragmentManager, ActivityNames.EventType.ANNOUNCEMENT, R.string.careportal_announcement) } sp.putBoolean(R.string.key_objectiveuseactions, true) @@ -301,7 +294,7 @@ class ActionsFragment : DaggerFragment() { if (!config.NSCLIENT) { statusLightHandler.updateStatusLights(cannulaAge, insulinAge, reservoirLevel, sensorAge, sensorLevel, pbAge, batteryLevel) - sensorLevelLabel.text = if (activeBgSource.sensorBatteryLevel == -1) "" else rh.gs(R.string.careportal_level_label) + sensorLevelLabel.text = if (activeBgSource.sensorBatteryLevel == -1) "" else rh.gs(R.string.level_label) } else { statusLightHandler.updateStatusLights(cannulaAge, insulinAge, null, sensorAge, null, pbAge, null) sensorLevelLabel.text = "" diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsPlugin.kt b/plugins/src/main/java/info/nightscout/plugins/general/actions/ActionsPlugin.kt similarity index 56% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsPlugin.kt rename to plugins/src/main/java/info/nightscout/plugins/general/actions/ActionsPlugin.kt index e7cfb73cba..3a0cffea9d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsPlugin.kt +++ b/plugins/src/main/java/info/nightscout/plugins/general/actions/ActionsPlugin.kt @@ -1,11 +1,11 @@ -package info.nightscout.androidaps.plugins.general.actions +package info.nightscout.plugins.general.actions import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R import info.nightscout.interfaces.Config import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginDescription import info.nightscout.interfaces.plugin.PluginType +import info.nightscout.plugins.R import info.nightscout.rx.logging.AAPSLogger import info.nightscout.shared.interfaces.ResourceHelper import javax.inject.Inject @@ -19,13 +19,13 @@ class ActionsPlugin @Inject constructor( config: Config ) : PluginBase( PluginDescription() - .mainType(PluginType.GENERAL) - .fragmentClass(ActionsFragment::class.qualifiedName) - .enableByDefault(config.APS || config.PUMPCONTROL) - .visibleByDefault(config.APS || config.PUMPCONTROL) - .pluginIcon(R.drawable.ic_action) - .pluginName(R.string.actions) - .shortName(R.string.actions_shortname) - .description(R.string.description_actions), + .mainType(PluginType.GENERAL) + .fragmentClass(ActionsFragment::class.qualifiedName) + .enableByDefault(config.APS || config.PUMPCONTROL) + .visibleByDefault(config.APS || config.PUMPCONTROL) + .pluginIcon(R.drawable.ic_action) + .pluginName(R.string.actions) + .shortName(R.string.actions_shortname) + .description(R.string.description_actions), aapsLogger, rh, injector ) diff --git a/app/src/main/java/info/nightscout/androidaps/skins/SkinButtonsOn.kt b/plugins/src/main/java/info/nightscout/plugins/skins/SkinButtonsOn.kt similarity index 83% rename from app/src/main/java/info/nightscout/androidaps/skins/SkinButtonsOn.kt rename to plugins/src/main/java/info/nightscout/plugins/skins/SkinButtonsOn.kt index e78c5dcd19..2da897baa7 100644 --- a/app/src/main/java/info/nightscout/androidaps/skins/SkinButtonsOn.kt +++ b/plugins/src/main/java/info/nightscout/plugins/skins/SkinButtonsOn.kt @@ -1,7 +1,7 @@ -package info.nightscout.androidaps.skins +package info.nightscout.plugins.skins import info.nightscout.interfaces.Config -import info.nightscout.androidaps.R +import info.nightscout.plugins.R import javax.inject.Inject import javax.inject.Singleton diff --git a/app/src/main/java/info/nightscout/androidaps/skins/SkinClassic.kt b/plugins/src/main/java/info/nightscout/plugins/skins/SkinClassic.kt similarity index 82% rename from app/src/main/java/info/nightscout/androidaps/skins/SkinClassic.kt rename to plugins/src/main/java/info/nightscout/plugins/skins/SkinClassic.kt index 543c963049..34b3fa3ec8 100644 --- a/app/src/main/java/info/nightscout/androidaps/skins/SkinClassic.kt +++ b/plugins/src/main/java/info/nightscout/plugins/skins/SkinClassic.kt @@ -1,14 +1,14 @@ -package info.nightscout.androidaps.skins +package info.nightscout.plugins.skins import android.util.DisplayMetrics import info.nightscout.interfaces.Config -import info.nightscout.androidaps.R -import info.nightscout.androidaps.databinding.OverviewFragmentBinding +import info.nightscout.plugins.R +import info.nightscout.plugins.databinding.OverviewFragmentBinding import javax.inject.Inject import javax.inject.Singleton @Singleton -class SkinClassic @Inject constructor(private val config: Config): SkinInterface { +class SkinClassic @Inject constructor(private val config: Config) : SkinInterface { override val description: Int get() = R.string.classic_description override val mainGraphHeight: Int get() = 200 diff --git a/app/src/main/java/info/nightscout/androidaps/skins/SkinInterface.kt b/plugins/src/main/java/info/nightscout/plugins/skins/SkinInterface.kt similarity index 94% rename from app/src/main/java/info/nightscout/androidaps/skins/SkinInterface.kt rename to plugins/src/main/java/info/nightscout/plugins/skins/SkinInterface.kt index 2e338955d5..327c3f5de5 100644 --- a/app/src/main/java/info/nightscout/androidaps/skins/SkinInterface.kt +++ b/plugins/src/main/java/info/nightscout/plugins/skins/SkinInterface.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.skins +package info.nightscout.plugins.skins import android.util.DisplayMetrics import android.util.TypedValue.COMPLEX_UNIT_PX @@ -6,9 +6,9 @@ import android.view.View import android.widget.LinearLayout import androidx.annotation.StringRes import androidx.constraintlayout.widget.ConstraintLayout -import info.nightscout.androidaps.R -import info.nightscout.androidaps.databinding.ActionsFragmentBinding -import info.nightscout.androidaps.databinding.OverviewFragmentBinding +import info.nightscout.plugins.R +import info.nightscout.plugins.databinding.ActionsFragmentBinding +import info.nightscout.plugins.databinding.OverviewFragmentBinding interface SkinInterface { diff --git a/app/src/main/java/info/nightscout/androidaps/skins/SkinLargeDisplay.kt b/plugins/src/main/java/info/nightscout/plugins/skins/SkinLargeDisplay.kt similarity index 81% rename from app/src/main/java/info/nightscout/androidaps/skins/SkinLargeDisplay.kt rename to plugins/src/main/java/info/nightscout/plugins/skins/SkinLargeDisplay.kt index ff02276574..3ef880d299 100644 --- a/app/src/main/java/info/nightscout/androidaps/skins/SkinLargeDisplay.kt +++ b/plugins/src/main/java/info/nightscout/plugins/skins/SkinLargeDisplay.kt @@ -1,14 +1,14 @@ -package info.nightscout.androidaps.skins +package info.nightscout.plugins.skins import android.util.DisplayMetrics -import info.nightscout.androidaps.R -import info.nightscout.androidaps.databinding.OverviewFragmentBinding import info.nightscout.interfaces.Config +import info.nightscout.plugins.R +import info.nightscout.plugins.databinding.OverviewFragmentBinding import javax.inject.Inject import javax.inject.Singleton @Singleton -class SkinLargeDisplay @Inject constructor(private val config: Config): SkinInterface { +class SkinLargeDisplay @Inject constructor(private val config: Config) : SkinInterface { override val description: Int get() = R.string.largedisplay_description override val mainGraphHeight: Int get() = 400 diff --git a/app/src/main/java/info/nightscout/androidaps/skins/SkinListPreference.kt b/plugins/src/main/java/info/nightscout/plugins/skins/SkinListPreference.kt similarity index 95% rename from app/src/main/java/info/nightscout/androidaps/skins/SkinListPreference.kt rename to plugins/src/main/java/info/nightscout/plugins/skins/SkinListPreference.kt index 51b546ce71..137e5749d3 100644 --- a/app/src/main/java/info/nightscout/androidaps/skins/SkinListPreference.kt +++ b/plugins/src/main/java/info/nightscout/plugins/skins/SkinListPreference.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.skins +package info.nightscout.plugins.skins import android.content.Context import android.util.AttributeSet diff --git a/app/src/main/java/info/nightscout/androidaps/skins/SkinLowRes.kt b/plugins/src/main/java/info/nightscout/plugins/skins/SkinLowRes.kt similarity index 88% rename from app/src/main/java/info/nightscout/androidaps/skins/SkinLowRes.kt rename to plugins/src/main/java/info/nightscout/plugins/skins/SkinLowRes.kt index 8d17b3bc79..d9e3c51848 100644 --- a/app/src/main/java/info/nightscout/androidaps/skins/SkinLowRes.kt +++ b/plugins/src/main/java/info/nightscout/plugins/skins/SkinLowRes.kt @@ -1,12 +1,12 @@ -package info.nightscout.androidaps.skins +package info.nightscout.plugins.skins import android.util.DisplayMetrics import android.view.View.GONE import android.view.ViewGroup import info.nightscout.interfaces.Config -import info.nightscout.androidaps.R -import info.nightscout.androidaps.databinding.ActionsFragmentBinding -import info.nightscout.androidaps.databinding.OverviewFragmentBinding +import info.nightscout.plugins.R +import info.nightscout.plugins.databinding.ActionsFragmentBinding +import info.nightscout.plugins.databinding.OverviewFragmentBinding import javax.inject.Inject import javax.inject.Singleton @@ -44,7 +44,7 @@ class SkinLowRes @Inject constructor(private val config: Config) : SkinInterface infoCard.elevation = 0F infoCard.radius = 0F val paramInfo = (infoCard.layoutParams as ViewGroup.MarginLayoutParams).apply { - setMargins(0,0,0,0) + setMargins(0, 0, 0, 0) } infoCard.layoutParams = paramInfo @@ -52,21 +52,21 @@ class SkinLowRes @Inject constructor(private val config: Config) : SkinInterface statusCard.radius = 0F statusCard.strokeWidth = 1 val paramStatus = (statusCard.layoutParams as ViewGroup.MarginLayoutParams).apply { - setMargins(0,0,0,0) + setMargins(0, 0, 0, 0) } statusCard.layoutParams = paramStatus nsclientCard.elevation = 0F nsclientCard.radius = 0F val paramNsClient = (nsclientCard.layoutParams as ViewGroup.MarginLayoutParams).apply { - setMargins(0,0,0,0) + setMargins(0, 0, 0, 0) } nsclientCard.layoutParams = paramNsClient graphCard.elevation = 0F graphCard.radius = 0F val paramGraph = (graphCard.layoutParams as ViewGroup.MarginLayoutParams).apply { - setMargins(0,0,0,0) + setMargins(0, 0, 0, 0) } graphCard.layoutParams = paramGraph diff --git a/app/src/main/java/info/nightscout/androidaps/skins/SkinProvider.kt b/plugins/src/main/java/info/nightscout/plugins/skins/SkinProvider.kt similarity index 82% rename from app/src/main/java/info/nightscout/androidaps/skins/SkinProvider.kt rename to plugins/src/main/java/info/nightscout/plugins/skins/SkinProvider.kt index b9d51adcda..aae1222ba9 100644 --- a/app/src/main/java/info/nightscout/androidaps/skins/SkinProvider.kt +++ b/plugins/src/main/java/info/nightscout/plugins/skins/SkinProvider.kt @@ -1,7 +1,7 @@ -package info.nightscout.androidaps.skins +package info.nightscout.plugins.skins -import info.nightscout.androidaps.R -import info.nightscout.androidaps.di.SkinsModule +import info.nightscout.plugins.R +import info.nightscout.plugins.di.SkinsModule import info.nightscout.shared.sharedPreferences.SP import okhttp3.internal.toImmutableMap import javax.inject.Inject diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/StatusLightHandler.kt b/plugins/src/main/java/info/nightscout/plugins/ui/StatusLightHandler.kt similarity index 96% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/overview/StatusLightHandler.kt rename to plugins/src/main/java/info/nightscout/plugins/ui/StatusLightHandler.kt index f503b2090a..2c32821997 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/StatusLightHandler.kt +++ b/plugins/src/main/java/info/nightscout/plugins/ui/StatusLightHandler.kt @@ -1,17 +1,16 @@ -package info.nightscout.androidaps.plugins.general.overview +package info.nightscout.plugins.ui import android.widget.TextView import androidx.annotation.StringRes -import info.nightscout.androidaps.R -import info.nightscout.database.impl.AppRepository -import info.nightscout.database.impl.ValueWrapper import info.nightscout.androidaps.interfaces.ActivePlugin -import info.nightscout.androidaps.plugins.pump.omnipod.eros.OmnipodErosPumpPlugin import info.nightscout.androidaps.utils.DecimalFormatter import info.nightscout.androidaps.utils.WarnColors import info.nightscout.database.entities.TherapyEvent +import info.nightscout.database.impl.AppRepository +import info.nightscout.database.impl.ValueWrapper import info.nightscout.interfaces.Config import info.nightscout.interfaces.pump.defs.PumpType +import info.nightscout.plugins.R import info.nightscout.plugins.sync.nsclient.extensions.age import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.sharedPreferences.SP @@ -77,7 +76,7 @@ class StatusLightHandler @Inject constructor( // The Omnipod Eros does not report its battery level. However, some RileyLink alternatives do. // Depending on the user's configuration, we will either show the battery level reported by the RileyLink or "n/a" // Pump instance check is needed because at startup, the pump can still be VirtualPumpPlugin and that will cause a crash - val erosBatteryLinkAvailable = pump.model() == PumpType.OMNIPOD_EROS && pump is OmnipodErosPumpPlugin && pump.isUseRileyLinkBatteryLevel + val erosBatteryLinkAvailable = pump.model() == PumpType.OMNIPOD_EROS && pump.isUseRileyLinkBatteryLevel() if (pump.model().supportBatteryLevel || erosBatteryLinkAvailable) { handleLevel(careportal_battery_level, R.string.key_statuslights_bat_critical, 26.0, R.string.key_statuslights_bat_warning, 51.0, pump.batteryLevel.toDouble(), "%") @@ -122,4 +121,4 @@ class StatusLightHandler @Inject constructor( handleLevel(view, criticalSetting, criticalDefaultValue, warnSetting, warnDefaultValue, level, units) } } -} +} \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_actions_cancelextbolus.xml b/plugins/src/main/res/drawable/ic_actions_cancel_extended_bolus.xml similarity index 100% rename from app/src/main/res/drawable/ic_actions_cancelextbolus.xml rename to plugins/src/main/res/drawable/ic_actions_cancel_extended_bolus.xml diff --git a/app/src/main/res/drawable/ic_arrow_drop_down_white_24dp.xml b/plugins/src/main/res/drawable/ic_arrow_drop_down_white_24dp.xml similarity index 100% rename from app/src/main/res/drawable/ic_arrow_drop_down_white_24dp.xml rename to plugins/src/main/res/drawable/ic_arrow_drop_down_white_24dp.xml diff --git a/app/src/main/res/drawable/ic_cancelbasal.xml b/plugins/src/main/res/drawable/ic_cancel_basal.xml similarity index 100% rename from app/src/main/res/drawable/ic_cancelbasal.xml rename to plugins/src/main/res/drawable/ic_cancel_basal.xml diff --git a/app/src/main/res/drawable/ic_cp_age_battery.xml b/plugins/src/main/res/drawable/ic_cp_age_battery.xml similarity index 100% rename from app/src/main/res/drawable/ic_cp_age_battery.xml rename to plugins/src/main/res/drawable/ic_cp_age_battery.xml diff --git a/app/src/main/res/drawable/ic_cp_age_cannula.xml b/plugins/src/main/res/drawable/ic_cp_age_cannula.xml similarity index 100% rename from app/src/main/res/drawable/ic_cp_age_cannula.xml rename to plugins/src/main/res/drawable/ic_cp_age_cannula.xml diff --git a/app/src/main/res/drawable/ic_cp_age_insulin.xml b/plugins/src/main/res/drawable/ic_cp_age_insulin.xml similarity index 100% rename from app/src/main/res/drawable/ic_cp_age_insulin.xml rename to plugins/src/main/res/drawable/ic_cp_age_insulin.xml diff --git a/app/src/main/res/drawable/ic_cp_age_sensor.xml b/plugins/src/main/res/drawable/ic_cp_age_sensor.xml similarity index 100% rename from app/src/main/res/drawable/ic_cp_age_sensor.xml rename to plugins/src/main/res/drawable/ic_cp_age_sensor.xml diff --git a/app/src/main/res/drawable/ic_crosstarget.xml b/plugins/src/main/res/drawable/ic_crosstarget.xml similarity index 100% rename from app/src/main/res/drawable/ic_crosstarget.xml rename to plugins/src/main/res/drawable/ic_crosstarget.xml diff --git a/app/src/main/res/layout/actions_fragment.xml b/plugins/src/main/res/layout/actions_fragment.xml similarity index 95% rename from app/src/main/res/layout/actions_fragment.xml rename to plugins/src/main/res/layout/actions_fragment.xml index 8136b4ca1b..d61ea35e9e 100644 --- a/app/src/main/res/layout/actions_fragment.xml +++ b/plugins/src/main/res/layout/actions_fragment.xml @@ -4,7 +4,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - tools:context=".plugins.general.actions.ActionsFragment"> + tools:context=".general.actions.ActionsFragment"> @@ -161,7 +161,7 @@ + tools:context="info.nightscout.plugins.general.actions.ActionsFragment"> @@ -28,7 +28,7 @@ android:gravity="center_vertical" android:paddingStart="0dp" android:paddingEnd="0dp" - android:text="@string/careportal_age_label" + android:text="@string/age_label" android:textSize="14sp" /> @@ -100,7 +100,7 @@ android:gravity="center_vertical" android:paddingStart="0dp" android:paddingEnd="0dp" - android:text="@string/careportal_age_label" + android:text="@string/age_label" android:textSize="14sp" /> @@ -246,7 +246,7 @@ android:gravity="center_vertical" android:paddingStart="0dp" android:paddingEnd="0dp" - android:text="@string/careportal_age_label" + android:text="@string/age_label" android:textSize="14sp" /> + tools:context="constraints.objectives.activities.ObjectivesExamDialog"> + app:layout_constraintTop_toBottomOf="@+id/exam_disabled_to"> + android:text="@string/objectives_previous_button" /> + android:text="@string/objectives_next_button" /> + tools:context=".constraints.objectives.ObjectivesFragment"> + tools:context="info.nightscout.androidaps.plugins.general.overview.OverviewFragment"> diff --git a/plugins/src/main/res/values/arrays.xml b/plugins/src/main/res/values/arrays.xml index 0e75db8ee1..e163555609 100644 --- a/plugins/src/main/res/values/arrays.xml +++ b/plugins/src/main/res/values/arrays.xml @@ -44,4 +44,19 @@ YpsoPump
+ + @string/child + @string/teenage + @string/adult + @string/resistantadult + @string/pregnant + + + @string/key_child + @string/key_teenage + @string/key_adult + @string/key_resistantadult + @string/key_pregnant + + \ No newline at end of file diff --git a/plugins/src/main/res/values/exam.xml b/plugins/src/main/res/values/exam.xml new file mode 100644 index 0000000000..6974c605bd --- /dev/null +++ b/plugins/src/main/res/values/exam.xml @@ -0,0 +1,230 @@ + + + What is true about DIA? + Duration of Insulin Action (DIA) + You should set the value for DIA in your profile. + The minimum allowed value is 5 hours. + https://androidaps.readthedocs.io/en/latest/EN/Configuration/Config-Builder.html?#insulin + If you are satisfied that the value for DIA that you used in your pump prior to AAPS worked well, there is no need to change this when you start looping. + You should determine for yourself the appropriate value for DIA. + Hypo Temp-Target + What is primary reason to set a hypo temp target? + To correct for hypos caused by incorrect basal rate settings. + To prevent AAPS from overcorrecting for a blood glucose rise caused by the fast acting carbs used to treat a hypo. + To correct for a hypo induced as a result of exercise. + To prevent blood glucose from going low if there is already a 0% temporary basal rate running. + https://androidaps.readthedocs.io/en/latest/EN/Usage/temptarget.html + Which profile can be used and configured offline? + Topic: Offline Profile + NS Profile can be used, but not configured. + https://androidaps.readthedocs.io/en/latest/EN/Configuration/Config-Builder.html#profile + Reasons for applying "Disconnect pump" in AAPS + What should be done when disconnecting the pump? + This is unnecessary as insulin will not be delivered if the pump is physically disconnected. + It prevents AAPS from accounting for insulin that was not delivered whilst the pump is physically disconnected.  + It will not stop insulin delivery if the pump remains connected. + It will send AAPS into open loop mode. + https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/FAQ.html#other-settings + AAPS Settings + AAPS Settings + What are the best practices for backing up your settings? + You do not need to export your settings provided that you make a note of them. + Export your settings after you finish completing an objective. + Export your settings after changing any of your settings. + Export your settings after you finish your initial set-up and have set your Preferences. + Export your settings locally using the maintenance menu. + Your settings file is found in the folder Internal Storage/AAPS/preferences on your phone. + Copy your preferences file to a safe location outside of your phone (e.g. by using a cloud drive, connecting a cable to a computer, email, etc.) + If your phone is damaged or lost, there are easy ways to remotely recover your settings without a backup. + https://androidaps.readthedocs.io/en/latest/EN/Usage/ExportImportSettings.html + https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/FAQ.html#what-emergency-equipment-is-recommended-to-take-with-me + Noisy CGM Readings + What should be done if CGM data is noisy? + Do nothing - AAPS will deal with it. + Disable the closed loop to avoid possible over or underdosing. + Replace consistently noisy or inaccurate sensors. + Verify that your CGM app provides smoothed data. + https://androidaps.readthedocs.io/en/latest/EN/Usage/Smoothing-Blood-Glucose-Data-in-xDrip.html#smoothing-blood-glucose-data + Exercise and Profiles + How can you use profiles to best help the system deal with aerobic exercise? + Do a profile switch to less than 100%. + Do a profile switch to more than 100%. + Leave the profile set to 100%. + Suspend the loop. + https://androidaps.readthedocs.io/en/latest/EN/Usage/temptarget.html#activity-temp-target + Exercise and Temporary Targets + How can you use temporary targets to best help the system deal with aerobic exercise? + Set an activity blood glucose target starting a suitable time before beginning exercise. + Set an activity blood glucose target after finishing exercise. + Leave your blood glucose target unchanged. + Wait until blood glucose drops below your hypo temp target and then eat 15 g of fast acting carbohydrates. + https://androidaps.readthedocs.io/en/latest/EN/Usage/temptarget.html#activity-temp-target + Disabled/Suspended loop + Do I receive insulin when the loop is disabled/suspended? + Yes, basal insulin continues to be delivered. + No, delivery of insulin is stopped. + Basal, ISF, and I:C Testing + When should these values be validated? + Before starting looping. + When experiencing frequent high or low blood glucose. + At least once per week. + Once set and validated, these values should not change over time. + https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/FAQ.html#androidaps-settings + Prerequisites + What is essential to set up and use AAPS? + Validated profile information (Basal, IC, ISF, DIA). + A computer with Android Studio installed and configured. + A supported phone. + A compatible insulin pump if you are planning to run a closed loop. + Nightscout, to keep a log of all data and review settings. + A Tidepool account. + A Google account. + A Github account. + Experience in programming or editing code. + A MiniMed 670G pump. + https://androidaps.readthedocs.io/en/latest/EN/Module/module.html + A Smartwatch. + A Supported CGM. + Prerequisites + What is essential to set up and use AAPS? + Validated information to set up a profile (ISF, I:C ratio, basal rates, DIA etc.). + A compatible Android device (e.g. mobile/cell phone, full Android watch, or tablet). + AAPS requires an internet connection in order to run in closed loop. + A supported CGM and appropriate app to receive blood glucose values on the phone/device. + https://androidaps.readthedocs.io/en/latest/EN/Module/module.html + Updating AAPS + Check all correct answers. + You need to have Git installed and configured on your computer. + When updated versions of AAPS are released, the earlier versions may be remotely limited after a specified time. + You should save and note the location of your keystore and use the same signing key for updates as for your previous installation. + Never update if the system is working well. + If you have difficulty building the apk, you can install an apk that has been built by a friend. + https://androidaps.readthedocs.io/en/latest/EN/Installing-AndroidAPS/Update-to-new-version.html#update-to-a-new-version-or-branch + Troubleshooting + Where can you look for help with AAPS? + You can ask for advice in the AAPS Users Facebook group. + You should read (and re-read) the AAPS documentation. + You can ask for advice and log technical problems or issues in the AAPS Discord. + You should ask your diabetes clinic/endocrinologist. + https://androidaps.readthedocs.io/en/latest/EN/Installing-AndroidAPS/Update-to-new-version.html#troubleshooting + https://www.facebook.com/groups/AndroidAPSUsers/ + https://discord.gg/4fQUWHZ4Mw + Insulin Plugins + Which insulin should you use with the Ultra-Rapid Oref plugin? + Fiasp® + NovoRapid®/Novolog® + Humalog® + Actrapid®/Humalin R®/"regular" human insulin. + https://androidaps.readthedocs.io/en/latest/EN/Configuration/Config-Builder.html#insulin + Sensitivity Plugins + Check all correct answers. + Sensitivity plugins allow AAPS to adjust for temporary or short-lived changes in insulin sensitivity (for example hormonal changes or issues with absorption at the infusion site). + Sensitivity plugins provide the user with suggested changes to basal rates, I:C ratios and ISF that can be used to edit profile. + Logging a cannula change will reset Autosens ratio back to 100%. + Some of the plugin options have configurable time ranges that can be set by the user. + https://androidaps.readthedocs.io/en/latest/EN/Configuration/Sensitivity-detection-and-COB.html + https://androidaps.readthedocs.io/en/latest/Usage/Open-APS-features.html?highlight=Autosens#autosens + Carb Entry Errors + What should you do if you’ve made an incorrect carb entry? + Delete the incorrect entry in Treatments and enter the correct new carb value. + Bolus with insulin using the infusion set prime menu. + Do nothing – AAPS will make the appropriate adjustments. + Bolus with insulin using the Insulin (bolus) button in Overview. + Insulin delivery/entry errors + What should you do if you received less insulin than the pump history suggests e.g. due to an occlusion, a failed cannula or forgetting to reattach the pump after a shower?  + Delete insulin data from Nightscout Careportal to remove it from the pump history. + Compare values in AAPS and pump history (if pump supports this). + Bolus a proportion of your calculated ‘missed’ insulin by either syringe/pen or using a prime. + Do nothing and allow AAPS to correct any resulting high blood glucose level. + Carbs on Board (COB) + How changing ISF value affects COB calculation? + Increasing ISF will take absorbing carbs a longer time + Increasing ISF will take absorbing carbs a shorter time + Increasing ISF will not affect calculated carbs absorption + How changing IC value affects COB calculation? + Increasing IC will take absorbing carbs a longer time + Increasing IC will take absorbing carbs a shorter time + Increasing IC will not affect calculated carbs absorption + How changing profile percentage affects COB calculation? + Setting profile to 150% will take absorbing carbs a longer time + Setting profile to 150% will take absorbing carbs a shorter time + Setting profile to 150% will not affect calculated carbs absorption + Insulin on Board (IOB) + IOB value is affected by issued temporary basals. + High temp basal will not be given when your blood sugar is below target. + Negative IOB for a substantial period in the absence of exercise suggests your profile is too strong and less insulin is needed in your settings. + Positive IOB for a substantial period suggests insulin resistance or unannounced meals. + Carb entry and boluses + Only grams should be used for estimating and recording carbohydrates consumed. + Carbohydrates consumed can be recorded using an appropriate exchange system (e.g. DAFNE "CHO" exchanges or European "Bread Units"). + AAPS uses a dynamic model to estimate carb “decay” and calculate COB. + If blood glucose levels are outside acceptable values (too low or too high) the bolus calculator can be used to provide suggestions for carb or insulin corrections. + https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/FAQ.html#insulin-to-carb-ratio-ic-g-u + e-carbs + What could you use e-carbs (extended carbs) for? + To schedule carbs in the future, possibly distributed over an interval (similar to an extended bolus distributing insulin over an interval). + For logging \'free\' exercise carbs you want to hide from AAPS. + e-carbs (distributed in the future) can assist AAPS in dealing with high fat/protein meals. + For logging rescue carbs you use to treat low blood glucose.  + https://androidaps.readthedocs.io/en/latest/EN/Usage/Extended-Carbs.html + Remote Monitoring + How can you monitor AAPS (for example for your child) remotely? + AAPSClient app, Nightscout app and Nightscout webpage all allow you to follow AAPS remotely. + Other apps (e.g. Dexcom follow, xDrip running in follow mode) allow you to follow some parameters (e.g. blood glucose/sensor values) remotely, but use different algorithms so may have inaccurate IOB or COB values. + To follow AAPS remotely, both devices must have internet access (e.g. via Wi-Fi or mobile/cellular network data). + AAPSClient used as a remote follower will both monitor and provide full control of AAPS. + https://androidaps.readthedocs.io/en/latest/EN/Children/Children.html + Insulin Sensitivity Factor (ISF) + Raising ISF values will lead to more insulin delivery to cover a specific amount of carbs. + Reducing ISF values lead to more insulin delivery to correct for an above target blood glucose. + Raising or lowering ISF has no effect on insulin delivery when blood glucose levels are below target. + ISF should be entered in your AAPS Preferences. + Changing the ISF value in your profile is enough to apply the change. + https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/FAQ.html#insulin-sensitivity-factor-isf-mmol-l-u-or-mg-dl-u + https://androidaps.readthedocs.io/en/latest/EN/Usage/Profiles.html + You can use more than one value for I:C ratio in your profile. + If you change your ISF in your profile you should always change your I:C ratio too. + Insulin to Carbohydrate Ratio (I:C ratio) + Higher I:C ratios lead to less insulin delivered for a given amount of carbs. + Lower I:C ratios lead to less insulin delivered for a given amount of carbs. + If you have 0 COB, changing the IC ratio will lead to a different amount of insulin to correct a given BG value. + IC will be different if you count bread (exchange) unit as 10g or 12g. + IC meaning is: How many bread (exchange) units are covered by 1U of insulin. + https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/FAQ.html#carbohydrate-to-insulin-ratio-cr-g-u + Profile Switching + When specifying a 90% profile switch, which answers are true? + Basal rates will be 10% lower. + ISF will be 10% higher. + The value of the I:C ratio will be a 10% lower number. + ISF and I:C ratios will be unchanged. + https://androidaps.readthedocs.io/en/latest/EN/Usage/Profiles.html?highlight=profile%20switch#profile-switch + Profile Switching + When specifying a 120% profile switch, which answers are true? + Target blood glucose will be 20% higher. + Basal rates will be 20% higher. + Target blood glucose will be unchanged. + ISF will be 20% higher. + Profile Switching + If you get up 2 hours earlier than usual, how should you notify AAPS of the change in your schedule? + Initiate a profile switch with a timeshift of 2 + Initiate a profile switch with a timeshift of -2 + Set an eating soon temporary target. + Do a profile switch to more than 100%.  + https://androidaps.readthedocs.io/en/latest/EN/Usage/Profiles.html?highlight=profile%20switch#timeshift + Changes to profiles + Basal rates, ISF, I:C ratios, etc., should be set in profiles. + Activating changes to your Nightscout Profile requires your AAPS phone to have an internet connection. + Editing profiles to change values is sufficient to enact any changes made. + Multiple profiles can be set up and selected to accommodate changing circumstances (e.g. hormonal changes, shift working, weekdays/weekend lifestyle). + https://androidaps.readthedocs.io/en/latest/EN/Module/module.html#good-individual-dosage-algorithm-for-your-diabetes-therapy + Help with basal rates + Where to go for help with basalrate etc. + Your diabetes team + Google + Facebook + + Other Medication. Please read the statement below and then check the box to accept the declaration. + AAPS reduces basal rates or suspends insulin delivery to raise blood sugar. Drugs in the class SGLT2 inhibitors (gliflozins) can prevent increases in blood glucose and therefore can produce a dangerous insulin deficiency leading to DKA. +\nCommon brand names are: Invokana®, Forxiga®, Jardiance®, Steglatro®, Suglat®, Apleway®, Deberza®, Synjardy®, Vokanamet®, Xigduo®.\n\nI hereby promise that I will not take such drugs when using AAPS or will deactivate the loop before using such drugs. + + diff --git a/plugins/src/main/res/values/objectives.xml b/plugins/src/main/res/values/objectives.xml new file mode 100644 index 0000000000..e8419700a8 --- /dev/null +++ b/plugins/src/main/res/values/objectives.xml @@ -0,0 +1,62 @@ + + + ObjectivesActionsUsed + ObjectivesLoopUsed + ObjectivesScaleUsed + objectives_request_code + ObjectivesmanualEnacts + + Start + Verify + %1$d. Objective + Objective %1$d not started + Objective %1$d not finished + Setting up visualization and monitoring, and analyzing basals and ratios + Verify that BG is available in Nightscout, and pump insulin data is being uploaded + Starting on an open loop + Run in Open Loop mode for a few days and manually enact lots of temp basals. Set up and use temporary and default temporary targets (e.g. for activity or hypo treatment carbs) + Understanding your open loop, including its temp basal recommendations + Based on that experience, decide what max basal should be, and set it on the pump and preferences + Starting to close the loop with Low Glucose Suspend + Run in closed loop with max IOB = 0 for a few days without too many LGS events + Tuning the closed loop, raising max IOB above 0 and gradually lowering BG targets + Run for a few days, and at least one night with no low BG alarms, before dropping BG + Adjust basals and ratios if needed, and then enable auto-sens + 1 week successful daytime looping with regular carb entry + Enabling additional features for daytime use, such as SMB + Enabling automation + You must read the wiki and rise maxIOB to get SMBs working fine! A good start is maxIOB=average mealbolus + 3 x max daily basal + Read the docs on how automation works. Set up your first simple rules. Instead of action let AAPS display only notification. When you are sure automation is triggered at the right time replace notification by real action. (https://androidaps.readthedocs.io/en/latest/EN/Usage/Automation.html) + BG available in NS + Pump status available in NS + Manual enacts + Accomplished: %1$s + Learn how to control AAPS + Perform different actions in AAPS + Set profile 90% for 10 min (Long-press profile name on Overview) + Simulate shower. Disconnect pump for 1h (Long-press on Open Loop) + ... and reconnect back the same way + Create custom temporary target with 10 min duration (Long-press on your current target) + In Config Builder enable Actions plugin, make it visible and display its content from top menu + Display content of Loop plugin + Use scale function by long-pressing BG chart + Enter + If you have at least 3 months of closed loop experience with other systems you might qualify for a code to skip objectives. See https://androidaps.readthedocs.io/en/latest/EN/Usage/Objectives.html#skip-objectives for details. + Code accepted + Code invalid + Prove your knowledge + Study the questions.  You are given four possible answers for each question. There may be more than one correct answer. Please check all those that are correct and select VERIFY. + Answering disabled until: %1$s + Wrong answer! + Next unfinished + Request code: %1$s + (check all correct answers) + https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/FAQ.html#what-to-do-when-taking-a-shower-or-bath + https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/Screenshots.html#the-homescreen + https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/Screenshots.html#config-builder + https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/Screenshots.html#the-homescreen + Not connected to the internet + Failed retrieve time + Objective requirements not met + + diff --git a/plugins/src/main/res/values/strings.xml b/plugins/src/main/res/values/strings.xml index 1e7a977353..f798645f51 100644 --- a/plugins/src/main/res/values/strings.xml +++ b/plugins/src/main/res/values/strings.xml @@ -234,9 +234,89 @@ PhoneChecker + ObjectivesbgIsAvailableInNS + ObjectivespumpStatusIsAvailableInNS + Completed, well done! Not completed yet Time elapsed + Maximal IOB set properly + BG available from selected source + Synchronization service has write permission + Loop enabled + APS selected + Closed mode enabled + OBJ + Learning program + Do you want reset objective start? You may lose your progress. + Next + Prev + Clear finished + Clear started + + + Actions + Some buttons to quickly access common features + ACT + TempBasal + Extended Bolus + Cancel Extended Bolus + Tools + History browser + Sensor + age: + level: + Insulin + Pump battery + Cannula + Use of Extended bolus feature will stop closed loop mode for the time of running extended bolus. Do you really want it? + Extended bolus delivery error + cannula age + patch pump age + Patch pump + + + openapsama_useautosens + use_smb + use_uam + openapsma_max_basal + openapsama_current_basal_safety_multiplier + openapsama_max_daily_safety_multiplier + treatmentssafety_maxbolus + lgsThreshold + openapsmb_max_iob + + Limiting extended bolus to %1$.1f U because of %2$s + Limiting carbs to %1$d g because of %2$s + Limiting IOB to %1$.1f U because of %2$s + + max basal multiplier + max daily basal multiplier + openapsma_max_iob + Safety + Pump is not temp basal capable + Closed loop mode disabled in preferences + Autosens disabled in preferences + SMB disabled in preferences + UAM disabled in preferences + UAM disabled because it rely on Oref1 sensitivity plugin + Running dev version. Closed loop is disabled. + Closed loop disabled because of running Extended bolus + SMB always and after carbs disabled because active BG source doesn\'t support advanced filtering + SMB not allowed in open loop mode + Increasing max basal value because setting is lower than your max basal in profile + max value in preferences + hard limit + Treatments safety + Please select patient type to setup safety limits + Child + Teenage + Adult + Insulin resistant adult + Pregnancy + Max allowed bolus [U] + Max allowed carbs [g] + Patient type statuslights_copy_ns @@ -276,6 +356,16 @@ Threshold critical pump battery level [%] Status lights Copy settings from NS + graph + insulin + Chart menu + blood glucose quality + blood glucose + outdated + APS Mode + Accept new temp basal: + CGM + QuickWizard ns_client_autoscroll @@ -483,8 +573,13 @@ UPLD NSClient malfunction. Consider NS and NSClient restart. - - ObjectivesbgIsAvailableInNS - ObjectivespumpStatusIsAvailableInNS + + skin + + Original skin + Low Resolution skin + Buttons are always displayed on bottom of screen + Large display + Skin \ No newline at end of file diff --git a/app/src/main/res/xml/pref_safety.xml b/plugins/src/main/res/xml/pref_safety.xml similarity index 100% rename from app/src/main/res/xml/pref_safety.xml rename to plugins/src/main/res/xml/pref_safety.xml diff --git a/plugins/src/test/java/info/nightscout/androidaps/HardLimitsMock.kt b/plugins/src/test/java/info/nightscout/androidaps/HardLimitsMock.kt new file mode 100644 index 0000000000..db6fc5800a --- /dev/null +++ b/plugins/src/test/java/info/nightscout/androidaps/HardLimitsMock.kt @@ -0,0 +1,84 @@ +package info.nightscout.androidaps + +import info.nightscout.core.main.R +import info.nightscout.interfaces.utils.HardLimits +import info.nightscout.shared.interfaces.ResourceHelper +import info.nightscout.shared.sharedPreferences.SP +import javax.inject.Inject +import kotlin.math.max +import kotlin.math.min + +class HardLimitsMock @Inject constructor( + private val sp: SP, + private val rh: ResourceHelper +) : HardLimits { + + companion object { + + private const val CHILD = 0 + private const val TEENAGE = 1 + private const val ADULT = 2 + private const val RESISTANT_ADULT = 3 + private const val PREGNANT = 4 + private val MAX_BOLUS = doubleArrayOf(5.0, 10.0, 17.0, 25.0, 60.0) + + // Very Hard Limits Ranges + // First value is the Lowest and second value is the Highest a Limit can define + val VERY_HARD_LIMIT_MIN_BG = doubleArrayOf(80.0, 180.0) + val VERY_HARD_LIMIT_MAX_BG = doubleArrayOf(90.0, 200.0) + val VERY_HARD_LIMIT_TARGET_BG = doubleArrayOf(80.0, 200.0) + + // Very Hard Limits Ranges for Temp Targets + val VERY_HARD_LIMIT_TEMP_MIN_BG = intArrayOf(72, 180) + val VERY_HARD_LIMIT_TEMP_MAX_BG = intArrayOf(72, 270) + val VERY_HARD_LIMIT_TEMP_TARGET_BG = intArrayOf(72, 200) + val MIN_DIA = doubleArrayOf(5.0, 5.0, 5.0, 5.0, 5.0) + val MAX_DIA = doubleArrayOf(9.0, 9.0, 9.0, 9.0, 10.0) + val MIN_IC = doubleArrayOf(2.0, 2.0, 2.0, 2.0, 0.3) + val MAX_IC = doubleArrayOf(100.0, 100.0, 100.0, 100.0, 100.0) + const val MIN_ISF = 2.0 // mgdl + const val MAX_ISF = 1000.0 // mgdl + val MAX_IOB_AMA = doubleArrayOf(3.0, 5.0, 7.0, 12.0, 25.0) + val MAX_IOB_SMB = doubleArrayOf(7.0, 13.0, 22.0, 30.0, 70.0) + val MAX_BASAL = doubleArrayOf(2.0, 5.0, 10.0, 12.0, 25.0) + + //LGS Hard limits + //No IOB at all + const val MAX_IOB_LGS = 0.0 + + } + + private fun loadAge(): Int = when (sp.getString(R.string.key_age, "")) { + rh.gs(R.string.key_child) -> CHILD + rh.gs(R.string.key_teenage) -> TEENAGE + rh.gs(R.string.key_adult) -> ADULT + rh.gs(R.string.key_resistantadult) -> RESISTANT_ADULT + rh.gs(R.string.key_pregnant) -> PREGNANT + else -> ADULT + } + + override fun maxBolus(): Double = MAX_BOLUS[loadAge()] + override fun maxIobAMA(): Double = MAX_IOB_AMA[loadAge()] + override fun maxIobSMB(): Double = MAX_IOB_SMB[loadAge()] + override fun maxBasal(): Double = MAX_BASAL[loadAge()] + override fun minDia(): Double = MIN_DIA[loadAge()] + override fun maxDia(): Double = MAX_DIA[loadAge()] + override fun minIC(): Double = MIN_IC[loadAge()] + override fun maxIC(): Double = MAX_IC[loadAge()] + + // safety checks + override fun checkHardLimits(value: Double, valueName: Int, lowLimit: Double, highLimit: Double): Boolean = + value == verifyHardLimits(value, valueName, lowLimit, highLimit) + + override fun isInRange(value: Double, lowLimit: Double, highLimit: Double): Boolean = + value in lowLimit..highLimit + + override fun verifyHardLimits(value: Double, valueName: Int, lowLimit: Double, highLimit: Double): Double { + var newValue = value + if (newValue < lowLimit || newValue > highLimit) { + newValue = max(newValue, lowLimit) + newValue = min(newValue, highLimit) + } + return newValue + } +} \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPluginTest.kt b/plugins/src/test/java/info/nightscout/plugins/constraints/objectives/ObjectivesPluginTest.kt similarity index 79% rename from app/src/test/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPluginTest.kt rename to plugins/src/test/java/info/nightscout/plugins/constraints/objectives/ObjectivesPluginTest.kt index 7a6ec7a912..1b2dfd051f 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPluginTest.kt +++ b/plugins/src/test/java/info/nightscout/plugins/constraints/objectives/ObjectivesPluginTest.kt @@ -1,14 +1,14 @@ -package info.nightscout.androidaps.plugins.constraints.objectives +package info.nightscout.plugins.constraints.objectives import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.interfaces.ActivePlugin -import info.nightscout.androidaps.logging.UserEntryLogger -import info.nightscout.androidaps.plugins.constraints.objectives.objectives.Objective import info.nightscout.interfaces.Config import info.nightscout.interfaces.constraints.Constraint +import info.nightscout.interfaces.constraints.Objectives +import info.nightscout.plugins.R +import info.nightscout.plugins.constraints.objectives.objectives.Objective import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.utils.DateUtil @@ -24,7 +24,6 @@ class ObjectivesPluginTest : TestBase() { @Mock lateinit var activePlugin: ActivePlugin @Mock lateinit var sp: SP @Mock lateinit var dateUtil: DateUtil - @Mock lateinit var uel: UserEntryLogger @Mock lateinit var config: Config private lateinit var objectivesPlugin: ObjectivesPlugin @@ -49,16 +48,16 @@ class ObjectivesPluginTest : TestBase() { } @Test fun notStartedObjectivesShouldLimitLoopInvocation() { - objectivesPlugin.objectives[ObjectivesPlugin.FIRST_OBJECTIVE].startedOn = 0 + objectivesPlugin.objectives[Objectives.FIRST_OBJECTIVE].startedOn = 0 var c = Constraint(true) c = objectivesPlugin.isLoopInvocationAllowed(c) Assert.assertEquals("Objectives: Objective 1 not started", c.getReasons(aapsLogger)) Assert.assertEquals(false, c.value()) - objectivesPlugin.objectives[ObjectivesPlugin.FIRST_OBJECTIVE].startedOn = dateUtil.now() + objectivesPlugin.objectives[Objectives.FIRST_OBJECTIVE].startedOn = dateUtil.now() } @Test fun notStartedObjective6ShouldLimitClosedLoop() { - objectivesPlugin.objectives[ObjectivesPlugin.MAXIOB_ZERO_CL_OBJECTIVE].startedOn = 0 + objectivesPlugin.objectives[Objectives.MAXIOB_ZERO_CL_OBJECTIVE].startedOn = 0 var c = Constraint(true) c = objectivesPlugin.isClosedLoopAllowed(c) Assert.assertEquals(true, c.getReasons(aapsLogger).contains("Objective 6 not started")) @@ -66,7 +65,7 @@ class ObjectivesPluginTest : TestBase() { } @Test fun notStartedObjective8ShouldLimitAutosensMode() { - objectivesPlugin.objectives[ObjectivesPlugin.AUTOSENS_OBJECTIVE].startedOn = 0 + objectivesPlugin.objectives[Objectives.AUTOSENS_OBJECTIVE].startedOn = 0 var c = Constraint(true) c = objectivesPlugin.isAutosensModeEnabled(c) Assert.assertEquals(true, c.getReasons(aapsLogger).contains("Objective 8 not started")) @@ -74,7 +73,7 @@ class ObjectivesPluginTest : TestBase() { } @Test fun notStartedObjective10ShouldLimitSMBMode() { - objectivesPlugin.objectives[ObjectivesPlugin.SMB_OBJECTIVE].startedOn = 0 + objectivesPlugin.objectives[Objectives.SMB_OBJECTIVE].startedOn = 0 var c = Constraint(true) c = objectivesPlugin.isSMBModeEnabled(c) Assert.assertEquals(true, c.getReasons(aapsLogger).contains("Objective 9 not started")) diff --git a/plugins/src/test/java/info/nightscout/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt b/plugins/src/test/java/info/nightscout/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt index 4fb8f57992..07674a4fa8 100644 --- a/plugins/src/test/java/info/nightscout/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt +++ b/plugins/src/test/java/info/nightscout/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt @@ -241,7 +241,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() { `when`(rh.gs(R.string.smscommunicator_pump_disconnected)).thenReturn("Pump disconnected") `when`(rh.gs(R.string.smscommunicator_code_from_authenticator_for)).thenReturn("from Authenticator app for: %1\$s followed by PIN") `when`(rh.gs(R.string.patient_name_default)).thenReturn("User") - `when`(rh.gs(R.string.invalidprofile)).thenReturn("Invalid profile !!!") + `when`(rh.gs(R.string.invalid_profile)).thenReturn("Invalid profile !!!") `when`(rh.gs(R.string.sms)).thenReturn("SMS") `when`(rh.gsNotLocalised(R.string.loopsuspended)).thenReturn("Loop suspended") `when`(rh.gsNotLocalised(R.string.smscommunicator_stopped_sms)).thenReturn("SMS Remote Service stopped. To reactivate it, use AAPS on master smartphone.") diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/source/GlimpPluginTest.kt b/plugins/src/test/java/info/nightscout/plugins/source/GlimpPluginTest.kt similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/source/GlimpPluginTest.kt rename to plugins/src/test/java/info/nightscout/plugins/source/GlimpPluginTest.kt diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/source/MM640GPluginTest.kt b/plugins/src/test/java/info/nightscout/plugins/source/MM640GPluginTest.kt similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/source/MM640GPluginTest.kt rename to plugins/src/test/java/info/nightscout/plugins/source/MM640GPluginTest.kt diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/source/NSClientPluginTest.kt b/plugins/src/test/java/info/nightscout/plugins/source/NSClientPluginTest.kt similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/source/NSClientPluginTest.kt rename to plugins/src/test/java/info/nightscout/plugins/source/NSClientPluginTest.kt diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/source/XdripPluginTest.kt b/plugins/src/test/java/info/nightscout/plugins/source/XdripPluginTest.kt similarity index 100% rename from app/src/test/java/info/nightscout/androidaps/plugins/source/XdripPluginTest.kt rename to plugins/src/test/java/info/nightscout/plugins/source/XdripPluginTest.kt diff --git a/pump/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/OmnipodErosPumpPlugin.java b/pump/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/OmnipodErosPumpPlugin.java index c9545286db..98df6b1c7f 100644 --- a/pump/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/OmnipodErosPumpPlugin.java +++ b/pump/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/OmnipodErosPumpPlugin.java @@ -1087,6 +1087,7 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley return getOperationNotSupportedWithCustomText(info.nightscout.androidaps.plugins.pump.common.R.string.pump_operation_not_supported_by_pump_driver); } + @Override public boolean isUseRileyLinkBatteryLevel() { return aapsOmnipodErosManager.isShowRileyLinkBatteryLevel(); } diff --git a/ui/src/main/java/info/nightscout/ui/activities/fragments/TreatmentsTempTargetFragment.kt b/ui/src/main/java/info/nightscout/ui/activities/fragments/TreatmentsTempTargetFragment.kt index 020ed558c6..f931b23cb9 100644 --- a/ui/src/main/java/info/nightscout/ui/activities/fragments/TreatmentsTempTargetFragment.kt +++ b/ui/src/main/java/info/nightscout/ui/activities/fragments/TreatmentsTempTargetFragment.kt @@ -259,7 +259,7 @@ class TreatmentsTempTargetFragment : DaggerFragment(), MenuProvider { private fun getConfirmationText(selectedItems: SparseArray): String { if (selectedItems.size() == 1) { val tempTarget = selectedItems.valueAt(0) - return "${rh.gs(R.string.careportal_temporarytarget)}: ${tempTarget.friendlyDescription(profileFunction.getUnits(), rh)}\n" + + return "${rh.gs(R.string.temporary_target)}: ${tempTarget.friendlyDescription(profileFunction.getUnits(), rh)}\n" + dateUtil.dateAndTimeString(tempTarget.timestamp) } return rh.gs(R.string.confirm_remove_multiple_items, selectedItems.size()) diff --git a/ui/src/main/java/info/nightscout/ui/dialogs/CareDialog.kt b/ui/src/main/java/info/nightscout/ui/dialogs/CareDialog.kt index 5454e2cae3..0069fea62e 100644 --- a/ui/src/main/java/info/nightscout/ui/dialogs/CareDialog.kt +++ b/ui/src/main/java/info/nightscout/ui/dialogs/CareDialog.kt @@ -27,6 +27,7 @@ import info.nightscout.database.impl.transactions.InsertIfNewByTimestampTherapyE import info.nightscout.interfaces.Constants import info.nightscout.interfaces.GlucoseUnit import info.nightscout.interfaces.profile.Profile +import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.utils.HtmlHelper import info.nightscout.rx.logging.LTag import info.nightscout.shared.interfaces.ResourceHelper @@ -52,17 +53,7 @@ class CareDialog : DialogFragmentWithDate() { private val disposable = CompositeDisposable() - enum class EventType { - BGCHECK, - SENSOR_INSERT, - BATTERY_CHANGE, - NOTE, - EXERCISE, - QUESTION, - ANNOUNCEMENT - } - - private var options: EventType = EventType.BGCHECK + private var options: ActivityNames.EventType = ActivityNames.EventType.BGCHECK //private var valuesWithUnit = mutableListOf() private var valuesWithUnit = mutableListOf() @@ -70,12 +61,6 @@ class CareDialog : DialogFragmentWithDate() { @StringRes private var event: Int = R.string.none - fun setOptions(options: EventType, @StringRes event: Int): CareDialog { - this.options = options - this.event = event - return this - } - private var _binding: DialogCareBinding? = null // This property is only valid between onCreateView and @@ -84,8 +69,6 @@ class CareDialog : DialogFragmentWithDate() { override fun onSaveInstanceState(savedInstanceState: Bundle) { super.onSaveInstanceState(savedInstanceState) - savedInstanceState.putDouble("bg", binding.bg.value) - savedInstanceState.putDouble("duration", binding.duration.value) savedInstanceState.putInt("event", event) savedInstanceState.putInt("options", options.ordinal) } @@ -104,48 +87,48 @@ class CareDialog : DialogFragmentWithDate() { savedInstanceState?.let { event = savedInstanceState.getInt("event", R.string.error) - options = EventType.values()[savedInstanceState.getInt("options", 0)] + options = ActivityNames.EventType.values()[savedInstanceState.getInt("options", 0)] } binding.icon.setImageResource( when (options) { - EventType.BGCHECK -> R.drawable.ic_cp_bgcheck - EventType.SENSOR_INSERT -> R.drawable.ic_cp_cgm_insert - EventType.BATTERY_CHANGE -> R.drawable.ic_cp_pump_battery - EventType.NOTE -> R.drawable.ic_cp_note - EventType.EXERCISE -> R.drawable.ic_cp_exercise - EventType.QUESTION -> R.drawable.ic_cp_question - EventType.ANNOUNCEMENT -> R.drawable.ic_cp_announcement + ActivityNames.EventType.BGCHECK -> R.drawable.ic_cp_bgcheck + ActivityNames.EventType.SENSOR_INSERT -> R.drawable.ic_cp_cgm_insert + ActivityNames.EventType.BATTERY_CHANGE -> R.drawable.ic_cp_pump_battery + ActivityNames.EventType.NOTE -> R.drawable.ic_cp_note + ActivityNames.EventType.EXERCISE -> R.drawable.ic_cp_exercise + ActivityNames.EventType.QUESTION -> R.drawable.ic_cp_question + ActivityNames.EventType.ANNOUNCEMENT -> R.drawable.ic_cp_announcement } ) binding.title.text = rh.gs( when (options) { - EventType.BGCHECK -> R.string.careportal_bgcheck - EventType.SENSOR_INSERT -> R.string.careportal_cgmsensorinsert - EventType.BATTERY_CHANGE -> R.string.careportal_pumpbatterychange - EventType.NOTE -> R.string.careportal_note - EventType.EXERCISE -> R.string.careportal_exercise - EventType.QUESTION -> R.string.careportal_question - EventType.ANNOUNCEMENT -> R.string.careportal_announcement + ActivityNames.EventType.BGCHECK -> R.string.careportal_bgcheck + ActivityNames.EventType.SENSOR_INSERT -> R.string.cgm_sensor_insert + ActivityNames.EventType.BATTERY_CHANGE -> R.string.pump_battery_change + ActivityNames.EventType.NOTE -> R.string.careportal_note + ActivityNames.EventType.EXERCISE -> R.string.careportal_exercise + ActivityNames.EventType.QUESTION -> R.string.careportal_question + ActivityNames.EventType.ANNOUNCEMENT -> R.string.careportal_announcement } ) when (options) { - EventType.QUESTION, - EventType.ANNOUNCEMENT, - EventType.BGCHECK -> { + ActivityNames.EventType.QUESTION, + ActivityNames.EventType.ANNOUNCEMENT, + ActivityNames.EventType.BGCHECK -> { binding.durationLayout.visibility = View.GONE } - EventType.SENSOR_INSERT, - EventType.BATTERY_CHANGE -> { + ActivityNames.EventType.SENSOR_INSERT, + ActivityNames.EventType.BATTERY_CHANGE -> { binding.bgLayout.visibility = View.GONE binding.bgsource.visibility = View.GONE binding.durationLayout.visibility = View.GONE } - EventType.NOTE, - EventType.EXERCISE -> { + ActivityNames.EventType.NOTE, + ActivityNames.EventType.EXERCISE -> { binding.bgLayout.visibility = View.GONE binding.bgsource.visibility = View.GONE } @@ -180,7 +163,7 @@ class CareDialog : DialogFragmentWithDate() { savedInstanceState?.getDouble("duration") ?: 0.0, 0.0, Constants.MAX_PROFILE_SWITCH_DURATION, 10.0, DecimalFormat("0"), false, binding.okcancel.ok ) - if (options == EventType.NOTE || options == EventType.QUESTION || options == EventType.ANNOUNCEMENT || options == EventType.EXERCISE) + if (options == ActivityNames.EventType.NOTE || options == ActivityNames.EventType.QUESTION || options == ActivityNames.EventType.ANNOUNCEMENT || options == ActivityNames.EventType.EXERCISE) binding.notesLayout.root.visibility = View.VISIBLE // independent to preferences binding.bgLabel.labelFor = binding.bg.editTextId binding.durationLabel.labelFor = binding.duration.editTextId @@ -200,19 +183,19 @@ class CareDialog : DialogFragmentWithDate() { val therapyEvent = TherapyEvent( timestamp = eventTime, type = when (options) { - EventType.BGCHECK -> TherapyEvent.Type.FINGER_STICK_BG_VALUE - EventType.SENSOR_INSERT -> TherapyEvent.Type.SENSOR_CHANGE - EventType.BATTERY_CHANGE -> TherapyEvent.Type.PUMP_BATTERY_CHANGE - EventType.NOTE -> TherapyEvent.Type.NOTE - EventType.EXERCISE -> TherapyEvent.Type.EXERCISE - EventType.QUESTION -> TherapyEvent.Type.QUESTION - EventType.ANNOUNCEMENT -> TherapyEvent.Type.ANNOUNCEMENT + ActivityNames.EventType.BGCHECK -> TherapyEvent.Type.FINGER_STICK_BG_VALUE + ActivityNames.EventType.SENSOR_INSERT -> TherapyEvent.Type.SENSOR_CHANGE + ActivityNames.EventType.BATTERY_CHANGE -> TherapyEvent.Type.PUMP_BATTERY_CHANGE + ActivityNames.EventType.NOTE -> TherapyEvent.Type.NOTE + ActivityNames.EventType.EXERCISE -> TherapyEvent.Type.EXERCISE + ActivityNames.EventType.QUESTION -> TherapyEvent.Type.QUESTION + ActivityNames.EventType.ANNOUNCEMENT -> TherapyEvent.Type.ANNOUNCEMENT }, glucoseUnit = TherapyEvent.GlucoseUnit.fromConstant(profileFunction.getUnits()) ) val actions: LinkedList = LinkedList() - if (options == EventType.BGCHECK || options == EventType.QUESTION || options == EventType.ANNOUNCEMENT) { + if (options == ActivityNames.EventType.BGCHECK || options == ActivityNames.EventType.QUESTION || options == ActivityNames.EventType.ANNOUNCEMENT) { val meterType = when { binding.meter.isChecked -> TherapyEvent.MeterType.FINGER @@ -226,7 +209,7 @@ class CareDialog : DialogFragmentWithDate() { valuesWithUnit.add(ValueWithUnit.fromGlucoseUnit(binding.bg.value, profileFunction.getUnits().asText)) valuesWithUnit.add(ValueWithUnit.TherapyEventMeterType(meterType)) } - if (options == EventType.NOTE || options == EventType.EXERCISE) { + if (options == ActivityNames.EventType.NOTE || options == ActivityNames.EventType.EXERCISE) { actions.add(rh.gs(R.string.duration_label) + ": " + rh.gs(R.string.format_mins, binding.duration.value.toInt())) therapyEvent.duration = T.mins(binding.duration.value.toLong()).msecs() valuesWithUnit.add(ValueWithUnit.Minute(binding.duration.value.toInt()).takeIf { !binding.duration.value.equals(0.0) }) @@ -242,13 +225,13 @@ class CareDialog : DialogFragmentWithDate() { therapyEvent.enteredBy = enteredBy val source = when (options) { - EventType.BGCHECK -> UserEntry.Sources.BgCheck - EventType.SENSOR_INSERT -> UserEntry.Sources.SensorInsert - EventType.BATTERY_CHANGE -> UserEntry.Sources.BatteryChange - EventType.NOTE -> UserEntry.Sources.Note - EventType.EXERCISE -> UserEntry.Sources.Exercise - EventType.QUESTION -> UserEntry.Sources.Question - EventType.ANNOUNCEMENT -> UserEntry.Sources.Announcement + ActivityNames.EventType.BGCHECK -> UserEntry.Sources.BgCheck + ActivityNames.EventType.SENSOR_INSERT -> UserEntry.Sources.SensorInsert + ActivityNames.EventType.BATTERY_CHANGE -> UserEntry.Sources.BatteryChange + ActivityNames.EventType.NOTE -> UserEntry.Sources.Note + ActivityNames.EventType.EXERCISE -> UserEntry.Sources.Exercise + ActivityNames.EventType.QUESTION -> UserEntry.Sources.Question + ActivityNames.EventType.ANNOUNCEMENT -> UserEntry.Sources.Announcement } activity?.let { activity -> diff --git a/ui/src/main/java/info/nightscout/ui/dialogs/ProfileSwitchDialog.kt b/ui/src/main/java/info/nightscout/ui/dialogs/ProfileSwitchDialog.kt index dbbbafabc3..52e31cee59 100644 --- a/ui/src/main/java/info/nightscout/ui/dialogs/ProfileSwitchDialog.kt +++ b/ui/src/main/java/info/nightscout/ui/dialogs/ProfileSwitchDialog.kt @@ -189,7 +189,7 @@ class ProfileSwitchDialog : DialogFragmentWithDate() { val target = defaultValueHelper.determineActivityTT() val units = profileFunction.getUnits() if (isTT) - actions.add(rh.gs(R.string.careportal_temporarytarget) + ": " + rh.gs(R.string.activity)) + actions.add(rh.gs(R.string.temporary_target) + ": " + rh.gs(R.string.activity)) activity?.let { activity -> val ps = profileFunction.buildProfileSwitch(profileStore, profileName, duration, percent, timeShift, eventTime) ?: return@let diff --git a/ui/src/main/java/info/nightscout/ui/dialogs/TempTargetDialog.kt b/ui/src/main/java/info/nightscout/ui/dialogs/TempTargetDialog.kt index e2229eaeb1..145fd54ec1 100644 --- a/ui/src/main/java/info/nightscout/ui/dialogs/TempTargetDialog.kt +++ b/ui/src/main/java/info/nightscout/ui/dialogs/TempTargetDialog.kt @@ -185,7 +185,7 @@ class TempTargetDialog : DialogFragmentWithDate() { actions.add(rh.gs(R.string.time) + ": " + dateUtil.dateAndTimeString(eventTime)) activity?.let { activity -> - OKDialog.showConfirmation(activity, rh.gs(R.string.careportal_temporarytarget), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { + OKDialog.showConfirmation(activity, rh.gs(R.string.temporary_target), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { val units = profileFunction.getUnits() when (reason) { rh.gs(R.string.eatingsoon) -> uel.log( diff --git a/app/src/main/res/drawable/cb_background_bg.xml b/ui/src/main/res/drawable/cb_background_bg.xml similarity index 97% rename from app/src/main/res/drawable/cb_background_bg.xml rename to ui/src/main/res/drawable/cb_background_bg.xml index cf493051a9..c03390f039 100644 --- a/app/src/main/res/drawable/cb_background_bg.xml +++ b/ui/src/main/res/drawable/cb_background_bg.xml @@ -1,7 +1,7 @@ - - - - + + + + diff --git a/app/src/main/res/drawable/cb_background_cob.xml b/ui/src/main/res/drawable/cb_background_cob.xml similarity index 97% rename from app/src/main/res/drawable/cb_background_cob.xml rename to ui/src/main/res/drawable/cb_background_cob.xml index b73f1f3b39..3e9d80413d 100644 --- a/app/src/main/res/drawable/cb_background_cob.xml +++ b/ui/src/main/res/drawable/cb_background_cob.xml @@ -1,7 +1,7 @@ - - - - + + + + diff --git a/app/src/main/res/drawable/cb_background_iob.xml b/ui/src/main/res/drawable/cb_background_iob.xml similarity index 97% rename from app/src/main/res/drawable/cb_background_iob.xml rename to ui/src/main/res/drawable/cb_background_iob.xml index bce5594f2a..22e0a92632 100644 --- a/app/src/main/res/drawable/cb_background_iob.xml +++ b/ui/src/main/res/drawable/cb_background_iob.xml @@ -1,7 +1,7 @@ - - - - + + + + diff --git a/app/src/main/res/drawable/cb_background_trend.xml b/ui/src/main/res/drawable/cb_background_trend.xml similarity index 97% rename from app/src/main/res/drawable/cb_background_trend.xml rename to ui/src/main/res/drawable/cb_background_trend.xml index 74e90acb2f..0c6f092e13 100644 --- a/app/src/main/res/drawable/cb_background_trend.xml +++ b/ui/src/main/res/drawable/cb_background_trend.xml @@ -1,7 +1,7 @@ - - - - + + + + diff --git a/app/src/main/res/drawable/cb_background_tt.xml b/ui/src/main/res/drawable/cb_background_tt.xml similarity index 100% rename from app/src/main/res/drawable/cb_background_tt.xml rename to ui/src/main/res/drawable/cb_background_tt.xml diff --git a/app/src/main/res/drawable/checkbox_bg_icon.xml b/ui/src/main/res/drawable/checkbox_bg_icon.xml similarity index 97% rename from app/src/main/res/drawable/checkbox_bg_icon.xml rename to ui/src/main/res/drawable/checkbox_bg_icon.xml index f22b42b4d9..c3e6f34a7b 100644 --- a/app/src/main/res/drawable/checkbox_bg_icon.xml +++ b/ui/src/main/res/drawable/checkbox_bg_icon.xml @@ -1,4 +1,4 @@ - - - - + + + + diff --git a/app/src/main/res/drawable/checkbox_cob_icon.xml b/ui/src/main/res/drawable/checkbox_cob_icon.xml similarity index 97% rename from app/src/main/res/drawable/checkbox_cob_icon.xml rename to ui/src/main/res/drawable/checkbox_cob_icon.xml index 391e1bf226..50fea3c9fa 100644 --- a/app/src/main/res/drawable/checkbox_cob_icon.xml +++ b/ui/src/main/res/drawable/checkbox_cob_icon.xml @@ -1,4 +1,4 @@ - - - - + + + + diff --git a/app/src/main/res/drawable/checkbox_iob_icon.xml b/ui/src/main/res/drawable/checkbox_iob_icon.xml similarity index 97% rename from app/src/main/res/drawable/checkbox_iob_icon.xml rename to ui/src/main/res/drawable/checkbox_iob_icon.xml index f9bcb46d52..0d93767769 100644 --- a/app/src/main/res/drawable/checkbox_iob_icon.xml +++ b/ui/src/main/res/drawable/checkbox_iob_icon.xml @@ -1,4 +1,4 @@ - - - - + + + + diff --git a/app/src/main/res/drawable/checkbox_trend_icon.xml b/ui/src/main/res/drawable/checkbox_trend_icon.xml similarity index 97% rename from app/src/main/res/drawable/checkbox_trend_icon.xml rename to ui/src/main/res/drawable/checkbox_trend_icon.xml index 025544c3fd..e9af90f4b7 100644 --- a/app/src/main/res/drawable/checkbox_trend_icon.xml +++ b/ui/src/main/res/drawable/checkbox_trend_icon.xml @@ -1,4 +1,4 @@ - - - - + + + + diff --git a/app/src/main/res/drawable/checkbox_tt_icon.xml b/ui/src/main/res/drawable/checkbox_tt_icon.xml similarity index 100% rename from app/src/main/res/drawable/checkbox_tt_icon.xml rename to ui/src/main/res/drawable/checkbox_tt_icon.xml diff --git a/app/src/main/res/drawable/ic_cp_basal_start.xml b/ui/src/main/res/drawable/ic_cp_basal_start.xml similarity index 100% rename from app/src/main/res/drawable/ic_cp_basal_start.xml rename to ui/src/main/res/drawable/ic_cp_basal_start.xml diff --git a/app/src/main/res/drawable/ic_loop_disabled.xml b/ui/src/main/res/drawable/ic_loop_disabled.xml similarity index 100% rename from app/src/main/res/drawable/ic_loop_disabled.xml rename to ui/src/main/res/drawable/ic_loop_disabled.xml diff --git a/app/src/main/res/drawable/ic_loop_disconnected.xml b/ui/src/main/res/drawable/ic_loop_disconnected.xml similarity index 100% rename from app/src/main/res/drawable/ic_loop_disconnected.xml rename to ui/src/main/res/drawable/ic_loop_disconnected.xml diff --git a/app/src/main/res/drawable/ic_loop_lgs.xml b/ui/src/main/res/drawable/ic_loop_lgs.xml similarity index 100% rename from app/src/main/res/drawable/ic_loop_lgs.xml rename to ui/src/main/res/drawable/ic_loop_lgs.xml diff --git a/app/src/main/res/drawable/ic_loop_open.xml b/ui/src/main/res/drawable/ic_loop_open.xml similarity index 100% rename from app/src/main/res/drawable/ic_loop_open.xml rename to ui/src/main/res/drawable/ic_loop_open.xml diff --git a/app/src/main/res/drawable/ic_loop_paused.xml b/ui/src/main/res/drawable/ic_loop_paused.xml similarity index 100% rename from app/src/main/res/drawable/ic_loop_paused.xml rename to ui/src/main/res/drawable/ic_loop_paused.xml diff --git a/app/src/main/res/drawable/ic_loop_reconnect.xml b/ui/src/main/res/drawable/ic_loop_reconnect.xml similarity index 100% rename from app/src/main/res/drawable/ic_loop_reconnect.xml rename to ui/src/main/res/drawable/ic_loop_reconnect.xml diff --git a/app/src/main/res/drawable/ic_loop_resume.xml b/ui/src/main/res/drawable/ic_loop_resume.xml similarity index 100% rename from app/src/main/res/drawable/ic_loop_resume.xml rename to ui/src/main/res/drawable/ic_loop_resume.xml diff --git a/app/src/main/res/drawable/ic_target_activity.xml b/ui/src/main/res/drawable/ic_target_activity.xml similarity index 100% rename from app/src/main/res/drawable/ic_target_activity.xml rename to ui/src/main/res/drawable/ic_target_activity.xml diff --git a/app/src/main/res/drawable/ic_target_cancel.xml b/ui/src/main/res/drawable/ic_target_cancel.xml similarity index 100% rename from app/src/main/res/drawable/ic_target_cancel.xml rename to ui/src/main/res/drawable/ic_target_cancel.xml diff --git a/app/src/main/res/drawable/ic_target_eatingsoon.xml b/ui/src/main/res/drawable/ic_target_eatingsoon.xml similarity index 100% rename from app/src/main/res/drawable/ic_target_eatingsoon.xml rename to ui/src/main/res/drawable/ic_target_eatingsoon.xml diff --git a/app/src/main/res/drawable/ic_target_hypo.xml b/ui/src/main/res/drawable/ic_target_hypo.xml similarity index 100% rename from app/src/main/res/drawable/ic_target_hypo.xml rename to ui/src/main/res/drawable/ic_target_hypo.xml diff --git a/app/src/main/res/drawable/ic_target_manual.xml b/ui/src/main/res/drawable/ic_target_manual.xml similarity index 100% rename from app/src/main/res/drawable/ic_target_manual.xml rename to ui/src/main/res/drawable/ic_target_manual.xml diff --git a/ui/src/main/res/layout/dialog_profileswitch.xml b/ui/src/main/res/layout/dialog_profileswitch.xml index ab8d8a775a..bdfbc38226 100644 --- a/ui/src/main/res/layout/dialog_profileswitch.xml +++ b/ui/src/main/res/layout/dialog_profileswitch.xml @@ -130,7 +130,7 @@ android:width="120dp" android:paddingStart="10dp" android:paddingEnd="10dp" - android:text="@string/careportal_newnstreatment_percentage_label" + android:text="@string/percentage_label" android:textAppearance="@style/TextAppearance.AppCompat.Small" android:textStyle="bold" /> @@ -139,7 +139,7 @@ android:layout_width="130dp" android:layout_height="40dp" android:layout_marginBottom="2dp" - app:customContentDescription="@string/careportal_newnstreatment_percentage_label" /> + app:customContentDescription="@string/percentage_label" /> diff --git a/ui/src/main/res/layout/dialog_temptarget.xml b/ui/src/main/res/layout/dialog_temptarget.xml index 4368906cf9..01af362cf1 100644 --- a/ui/src/main/res/layout/dialog_temptarget.xml +++ b/ui/src/main/res/layout/dialog_temptarget.xml @@ -32,7 +32,7 @@ android:layout_gravity="center" android:layout_marginStart="10dp" android:layout_marginEnd="10dp" - android:text="@string/careportal_temporarytarget" + android:text="@string/temporary_target" android:textAlignment="center" android:textAppearance="?android:attr/textAppearanceLarge" /> diff --git a/ui/src/main/res/layout/treatments_fragment.xml b/ui/src/main/res/layout/treatments_fragment.xml index 3e2dd0d83f..3391381986 100644 --- a/ui/src/main/res/layout/treatments_fragment.xml +++ b/ui/src/main/res/layout/treatments_fragment.xml @@ -32,12 +32,12 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="@string/tempbasal_label" - android:icon="@drawable/ic_actions_starttempbasal" /> + android:icon="@drawable/ic_actions_start_temp_basal" /> Reuse %1$d%% %2$dh Time shift + Percentage Suspend loop for 1h @@ -74,6 +75,12 @@ Disconnect pump for 3 h Resume Reconnect Pump + 15 mins + 30 mins + 1 hour + 2 hours + 3 hours + 10 hours wizard_calculation_visible @@ -86,6 +93,10 @@ 2h Result: %1$s %2$s Missing %1$d g + current blood glucose + Carb time + set carb timer alarm + Show calcuation No records available @@ -138,4 +149,7 @@ DPV Default profile Invalid % entry + + Basal rate +