From 16bf64129d4911c993aca9bbf256816e29df81c7 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 9 Dec 2022 15:34:11 +0100 Subject: [PATCH] :pump:virtual --- app/build.gradle | 3 +- .../activities/MyPreferenceFragment.kt | 2 +- .../nightscout/androidaps/di/AppComponent.kt | 4 +- .../androidaps/di/PluginsListModule.kt | 2 +- .../androidaps/pump/PumpEnactResultTest.kt | 2 +- crowdin.yml | 2 + .../nightscout/plugins/di/PluginsModule.kt | 1 - .../plugins/source/RandomBgPlugin.kt | 6 +-- plugins/main/src/main/res/values/arrays.xml | 32 ---------------- plugins/main/src/main/res/values/strings.xml | 10 ----- pump/virtual/.gitignore | 1 + pump/virtual/build.gradle | 27 ++++++++++++++ pump/virtual/consumer-rules.pro | 0 pump/virtual/proguard-rules.pro | 21 +++++++++++ pump/virtual/src/main/AndroidManifest.xml | 3 ++ .../pump/virtual/VirtualPumpFragment.kt | 7 ++-- .../pump/virtual/VirtualPumpPlugin.kt | 7 ++-- .../pump/virtual}/di/VirtualPumpModule.kt | 6 +-- .../events/EventVirtualPumpUpdateGui.kt | 2 +- .../extensions/PumpEnactResultExtension.kt | 2 +- .../main/res/layout/virtual_pump_fragment.xml | 2 +- pump/virtual/src/main/res/values/arrays.xml | 35 ++++++++++++++++++ pump/virtual/src/main/res/values/strings.xml | 13 +++++++ .../src/main/res/xml/pref_virtual_pump.xml | 0 .../info/nightscout/androidaps/TestBase.kt | 37 +++++++++++++++++++ .../pump/virtual/VirtualPumpPluginUTest.kt | 10 ++--- settings.gradle | 1 + 27 files changed, 168 insertions(+), 70 deletions(-) create mode 100644 pump/virtual/.gitignore create mode 100644 pump/virtual/build.gradle create mode 100644 pump/virtual/consumer-rules.pro create mode 100644 pump/virtual/proguard-rules.pro create mode 100644 pump/virtual/src/main/AndroidManifest.xml rename {plugins/main/src/main/java/info/nightscout/plugins => pump/virtual/src/main/java/info/nightscout}/pump/virtual/VirtualPumpFragment.kt (95%) rename {plugins/main/src/main/java/info/nightscout/plugins => pump/virtual/src/main/java/info/nightscout}/pump/virtual/VirtualPumpPlugin.kt (98%) rename {plugins/main/src/main/java/info/nightscout/plugins => pump/virtual/src/main/java/info/nightscout/pump/virtual}/di/VirtualPumpModule.kt (75%) rename {plugins/main/src/main/java/info/nightscout/plugins => pump/virtual/src/main/java/info/nightscout}/pump/virtual/events/EventVirtualPumpUpdateGui.kt (65%) rename {plugins/main/src/main/java/info/nightscout/plugins => pump/virtual/src/main/java/info/nightscout/pump/virtual}/extensions/PumpEnactResultExtension.kt (97%) rename {plugins/main => pump/virtual}/src/main/res/layout/virtual_pump_fragment.xml (99%) create mode 100644 pump/virtual/src/main/res/values/arrays.xml create mode 100644 pump/virtual/src/main/res/values/strings.xml rename {plugins/main => pump/virtual}/src/main/res/xml/pref_virtual_pump.xml (100%) create mode 100644 pump/virtual/src/test/java/info/nightscout/androidaps/TestBase.kt rename {plugins/main/src/test/java/info/nightscout/plugins => pump/virtual/src/test/java/info/nightscout}/pump/virtual/VirtualPumpPluginUTest.kt (87%) diff --git a/app/build.gradle b/app/build.gradle index 28cc2ab5b7..0c80acd2d7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -218,10 +218,11 @@ dependencies { implementation project(':pump:medtronic') implementation project(':pump:pump-common') implementation project(':pump:pump-core') - implementation project(':pump:rileylink') implementation project(':pump:omnipod-common') implementation project(':pump:omnipod-eros') implementation project(':pump:omnipod-dash') + implementation project(':pump:rileylink') + implementation project(':pump:virtual') implementation project(':workflow') implementation fileTree(include: ['*.jar'], dir: 'libs') 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 b7ceb50785..b6b06fb5c5 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/MyPreferenceFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/MyPreferenceFragment.kt @@ -48,7 +48,6 @@ import info.nightscout.plugins.general.autotune.AutotunePlugin import info.nightscout.plugins.general.smsCommunicator.SmsCommunicatorPlugin import info.nightscout.plugins.general.wear.WearPlugin import info.nightscout.plugins.general.xdripStatusline.StatusLinePlugin -import info.nightscout.plugins.pump.virtual.VirtualPumpPlugin import info.nightscout.plugins.source.AidexPlugin import info.nightscout.plugins.source.DexcomPlugin import info.nightscout.plugins.source.EversensePlugin @@ -63,6 +62,7 @@ import info.nightscout.plugins.sync.tidepool.TidepoolPlugin import info.nightscout.pump.combo.ComboPlugin import info.nightscout.pump.combov2.ComboV2Plugin import info.nightscout.pump.diaconn.DiaconnG8Plugin +import info.nightscout.pump.virtual.VirtualPumpPlugin import info.nightscout.rx.bus.RxBus import info.nightscout.rx.events.EventPreferenceChange import info.nightscout.rx.events.EventRebuildTabs 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 ba16aa612b..7ba9ed8947 100644 --- a/app/src/main/java/info/nightscout/androidaps/di/AppComponent.kt +++ b/app/src/main/java/info/nightscout/androidaps/di/AppComponent.kt @@ -32,6 +32,7 @@ import info.nightscout.pump.dana.di.DanaHistoryModule import info.nightscout.pump.dana.di.DanaModule import info.nightscout.pump.danars.di.DanaRSModule import info.nightscout.pump.diaconn.di.DiaconnG8Module +import info.nightscout.pump.virtual.di.VirtualPumpModule import info.nightscout.rx.di.RxModule import info.nightscout.shared.di.SharedModule import info.nightscout.shared.impl.di.SharedImplModule @@ -83,7 +84,8 @@ import javax.inject.Singleton OmnipodDashModule::class, OmnipodErosModule::class, PumpCommonModule::class, - RileyLinkModule::class + RileyLinkModule::class, + VirtualPumpModule::class ] ) interface AppComponent : AndroidInjector { 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 40922d18dc..3010832bd9 100644 --- a/app/src/main/java/info/nightscout/androidaps/di/PluginsListModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/di/PluginsListModule.kt @@ -41,7 +41,6 @@ import info.nightscout.plugins.general.wear.WearPlugin import info.nightscout.plugins.general.xdripStatusline.StatusLinePlugin import info.nightscout.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.plugins.profile.ProfilePlugin -import info.nightscout.plugins.pump.virtual.VirtualPumpPlugin import info.nightscout.plugins.source.AidexPlugin import info.nightscout.plugins.source.DexcomPlugin import info.nightscout.plugins.source.GlimpPlugin @@ -59,6 +58,7 @@ import info.nightscout.plugins.sync.tidepool.TidepoolPlugin import info.nightscout.pump.combo.ComboPlugin import info.nightscout.pump.combov2.ComboV2Plugin import info.nightscout.pump.diaconn.DiaconnG8Plugin +import info.nightscout.pump.virtual.VirtualPumpPlugin import info.nightscout.sensitivity.SensitivityAAPSPlugin import info.nightscout.sensitivity.SensitivityOref1Plugin import info.nightscout.sensitivity.SensitivityWeightedAveragePlugin diff --git a/app/src/test/java/info/nightscout/androidaps/pump/PumpEnactResultTest.kt b/app/src/test/java/info/nightscout/androidaps/pump/PumpEnactResultTest.kt index 30c579d7b8..70a588210d 100644 --- a/app/src/test/java/info/nightscout/androidaps/pump/PumpEnactResultTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/pump/PumpEnactResultTest.kt @@ -6,7 +6,7 @@ import info.nightscout.androidaps.TestBaseWithProfile import info.nightscout.core.pump.toHtml import info.nightscout.interfaces.pump.PumpEnactResult import info.nightscout.plugins.aps.loop.extensions.json -import info.nightscout.plugins.extensions.toText +import info.nightscout.pump.virtual.extensions.toText import info.nightscout.plugins.sync.nsShared.extensions.log import org.json.JSONObject import org.junit.jupiter.api.Assertions diff --git a/crowdin.yml b/crowdin.yml index bad417b724..42dc0118d9 100644 --- a/crowdin.yml +++ b/crowdin.yml @@ -71,6 +71,8 @@ files: translation: /pump/omnipod-eros/src/main/res/values-%android_code%/strings.xml - source: /pump/rileylink/src/main/res/values/strings.xml translation: /pump/rileylink/src/main/res/values-%android_code%/strings.xml + - source: /pump/virtual/src/main/res/values/strings.xml + translation: /pump/virtual/src/main/res/values-%android_code%/strings.xml - source: /insight/src/main/res/values/strings.xml translation: /insight/src/main/res/values-%android_code%/strings.xml - source: /insight/src/main/res/values/alert_codes.xml diff --git a/plugins/main/src/main/java/info/nightscout/plugins/di/PluginsModule.kt b/plugins/main/src/main/java/info/nightscout/plugins/di/PluginsModule.kt index 412cd23353..35e8fe88ad 100644 --- a/plugins/main/src/main/java/info/nightscout/plugins/di/PluginsModule.kt +++ b/plugins/main/src/main/java/info/nightscout/plugins/di/PluginsModule.kt @@ -18,7 +18,6 @@ import info.nightscout.plugins.iob.iobCobCalculator.data.AutosensDataObject SMSCommunicatorModule::class, ProfileModule::class, SourceModule::class, - VirtualPumpModule::class, SkinsModule::class, SkinsUiModule::class, ActionsModule::class, diff --git a/plugins/main/src/main/java/info/nightscout/plugins/source/RandomBgPlugin.kt b/plugins/main/src/main/java/info/nightscout/plugins/source/RandomBgPlugin.kt index 5fec0528bc..c11fbbfe47 100644 --- a/plugins/main/src/main/java/info/nightscout/plugins/source/RandomBgPlugin.kt +++ b/plugins/main/src/main/java/info/nightscout/plugins/source/RandomBgPlugin.kt @@ -14,9 +14,9 @@ import info.nightscout.interfaces.XDripBroadcast import info.nightscout.interfaces.plugin.PluginBase import info.nightscout.interfaces.plugin.PluginDescription import info.nightscout.interfaces.plugin.PluginType +import info.nightscout.interfaces.pump.VirtualPump import info.nightscout.interfaces.source.BgSource import info.nightscout.plugins.R -import info.nightscout.plugins.pump.virtual.VirtualPumpPlugin import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.LTag import info.nightscout.shared.interfaces.ResourceHelper @@ -39,7 +39,7 @@ class RandomBgPlugin @Inject constructor( private val sp: SP, private val repository: AppRepository, private val xDripBroadcast: XDripBroadcast, - private val virtualPumpPlugin: VirtualPumpPlugin, + private val virtualPump: VirtualPump, private val config: Config ) : PluginBase( PluginDescription() @@ -94,7 +94,7 @@ class RandomBgPlugin @Inject constructor( } override fun specialEnableCondition(): Boolean { - return isRunningTest() || config.isUnfinishedMode() || virtualPumpPlugin.isEnabled() && config.isEngineeringMode() + return isRunningTest() || config.isUnfinishedMode() || virtualPump.isEnabled() && config.isEngineeringMode() } private fun handleNewData() { diff --git a/plugins/main/src/main/res/values/arrays.xml b/plugins/main/src/main/res/values/arrays.xml index 0e75db8ee1..3360615473 100644 --- a/plugins/main/src/main/res/values/arrays.xml +++ b/plugins/main/src/main/res/values/arrays.xml @@ -12,36 +12,4 @@ @string/value_system_theme - - Generic AAPS - MDI - Accu-Chek Combo - Accu-Chek Spirit - Accu-Chek Insight - Accu-Chek Solo - Animas Ping - Animas Vibe - Cellnovo - DanaR - DanaR Korean - DanaRS - DanaRv2 - DanaI - Diaconn G8 - Eoflow Eopatch2 - Medtronic 512/712 - Medtronic 515/715 - Medtronic 522/722 - Medtronic 523/723 (Revel) - Medtronic 554/754 (Veo) - Medtronic 640G - Omnipod Dash - Omnipod Eros - Tandem t:slim - Tandem t:flex - Tandem t:slim G4 - Tandem t:slim X2 - YpsoPump - - \ No newline at end of file diff --git a/plugins/main/src/main/res/values/strings.xml b/plugins/main/src/main/res/values/strings.xml index 5087bd5cec..0e61329d58 100644 --- a/plugins/main/src/main/res/values/strings.xml +++ b/plugins/main/src/main/res/values/strings.xml @@ -344,16 +344,6 @@ Graph scale Graph - - Virtual Pump Type - Pump Definition - Bolus: Step=%1$s\nExtended Bolus: [Step=%2$s, Duration=%3$smin-%4$sh]\nBasal: Step=%5$s\nTBR: %6$s (by %7$s), Duration=%8$smin-%9$sh\n%10$s - - VPUMP - Pump integration for pumps which don\'t have any driver yet (Open Loop) - VIRTUAL PUMP - Virtual pump settings - dexcom_lognssensorchange last_processed_glunovo_timestamp diff --git a/pump/virtual/.gitignore b/pump/virtual/.gitignore new file mode 100644 index 0000000000..796b96d1c4 --- /dev/null +++ b/pump/virtual/.gitignore @@ -0,0 +1 @@ +/build diff --git a/pump/virtual/build.gradle b/pump/virtual/build.gradle new file mode 100644 index 0000000000..3f2bc9b9ac --- /dev/null +++ b/pump/virtual/build.gradle @@ -0,0 +1,27 @@ +plugins { + id 'com.android.library' + id 'kotlin-android' + id 'kotlin-kapt' + id 'kotlin-allopen' + id 'com.hiya.jacoco-android' +} + +apply from: "${project.rootDir}/core/main/android_dependencies.gradle" +apply from: "${project.rootDir}/core/main/android_module_dependencies.gradle" +apply from: "${project.rootDir}/core/main/allopen_dependencies.gradle" +apply from: "${project.rootDir}/core/main/test_dependencies.gradle" +apply from: "${project.rootDir}/core/main/jacoco_global.gradle" + +android { + + namespace 'info.nightscout.pump.virtual' +} + +dependencies { + implementation project(':app-wear-shared:shared') + implementation project(':database:entities') + implementation project(':core:interfaces') + implementation project(':core:main') + implementation project(':core:ui') + implementation project(':core:utils') +} \ No newline at end of file diff --git a/pump/virtual/consumer-rules.pro b/pump/virtual/consumer-rules.pro new file mode 100644 index 0000000000..e69de29bb2 diff --git a/pump/virtual/proguard-rules.pro b/pump/virtual/proguard-rules.pro new file mode 100644 index 0000000000..f1b424510d --- /dev/null +++ b/pump/virtual/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/pump/virtual/src/main/AndroidManifest.xml b/pump/virtual/src/main/AndroidManifest.xml new file mode 100644 index 0000000000..0a0938ae37 --- /dev/null +++ b/pump/virtual/src/main/AndroidManifest.xml @@ -0,0 +1,3 @@ + + + diff --git a/plugins/main/src/main/java/info/nightscout/plugins/pump/virtual/VirtualPumpFragment.kt b/pump/virtual/src/main/java/info/nightscout/pump/virtual/VirtualPumpFragment.kt similarity index 95% rename from plugins/main/src/main/java/info/nightscout/plugins/pump/virtual/VirtualPumpFragment.kt rename to pump/virtual/src/main/java/info/nightscout/pump/virtual/VirtualPumpFragment.kt index f528521824..15c1cf15b0 100644 --- a/plugins/main/src/main/java/info/nightscout/plugins/pump/virtual/VirtualPumpFragment.kt +++ b/pump/virtual/src/main/java/info/nightscout/pump/virtual/VirtualPumpFragment.kt @@ -1,4 +1,4 @@ -package info.nightscout.plugins.pump.virtual +package info.nightscout.pump.virtual import android.os.Bundle import android.os.Handler @@ -11,9 +11,8 @@ import info.nightscout.core.extensions.toStringFull import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.interfaces.iob.IobCobCalculator import info.nightscout.interfaces.profile.ProfileFunction -import info.nightscout.plugins.R -import info.nightscout.plugins.databinding.VirtualPumpFragmentBinding -import info.nightscout.plugins.pump.virtual.events.EventVirtualPumpUpdateGui +import info.nightscout.pump.virtual.databinding.VirtualPumpFragmentBinding +import info.nightscout.pump.virtual.events.EventVirtualPumpUpdateGui import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.bus.RxBus import info.nightscout.rx.events.EventExtendedBolusChange diff --git a/plugins/main/src/main/java/info/nightscout/plugins/pump/virtual/VirtualPumpPlugin.kt b/pump/virtual/src/main/java/info/nightscout/pump/virtual/VirtualPumpPlugin.kt similarity index 98% rename from plugins/main/src/main/java/info/nightscout/plugins/pump/virtual/VirtualPumpPlugin.kt rename to pump/virtual/src/main/java/info/nightscout/pump/virtual/VirtualPumpPlugin.kt index 0bf57732be..9db3437861 100644 --- a/plugins/main/src/main/java/info/nightscout/plugins/pump/virtual/VirtualPumpPlugin.kt +++ b/pump/virtual/src/main/java/info/nightscout/pump/virtual/VirtualPumpPlugin.kt @@ -1,4 +1,4 @@ -package info.nightscout.plugins.pump.virtual +package info.nightscout.pump.virtual import android.os.SystemClock import androidx.preference.PreferenceFragmentCompat @@ -28,9 +28,8 @@ import info.nightscout.interfaces.pump.defs.PumpDescription import info.nightscout.interfaces.pump.defs.PumpType import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.utils.TimeChangeType -import info.nightscout.plugins.R -import info.nightscout.plugins.extensions.toText -import info.nightscout.plugins.pump.virtual.events.EventVirtualPumpUpdateGui +import info.nightscout.pump.virtual.events.EventVirtualPumpUpdateGui +import info.nightscout.pump.virtual.extensions.toText import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.bus.RxBus import info.nightscout.rx.events.EventOverviewBolusProgress diff --git a/plugins/main/src/main/java/info/nightscout/plugins/di/VirtualPumpModule.kt b/pump/virtual/src/main/java/info/nightscout/pump/virtual/di/VirtualPumpModule.kt similarity index 75% rename from plugins/main/src/main/java/info/nightscout/plugins/di/VirtualPumpModule.kt rename to pump/virtual/src/main/java/info/nightscout/pump/virtual/di/VirtualPumpModule.kt index f931269ecf..156c1bd0f5 100644 --- a/plugins/main/src/main/java/info/nightscout/plugins/di/VirtualPumpModule.kt +++ b/pump/virtual/src/main/java/info/nightscout/pump/virtual/di/VirtualPumpModule.kt @@ -1,11 +1,11 @@ -package info.nightscout.plugins.di +package info.nightscout.pump.virtual.di import dagger.Binds import dagger.Module import dagger.android.ContributesAndroidInjector import info.nightscout.interfaces.pump.VirtualPump -import info.nightscout.plugins.pump.virtual.VirtualPumpFragment -import info.nightscout.plugins.pump.virtual.VirtualPumpPlugin +import info.nightscout.pump.virtual.VirtualPumpFragment +import info.nightscout.pump.virtual.VirtualPumpPlugin @Module( includes = [ diff --git a/plugins/main/src/main/java/info/nightscout/plugins/pump/virtual/events/EventVirtualPumpUpdateGui.kt b/pump/virtual/src/main/java/info/nightscout/pump/virtual/events/EventVirtualPumpUpdateGui.kt similarity index 65% rename from plugins/main/src/main/java/info/nightscout/plugins/pump/virtual/events/EventVirtualPumpUpdateGui.kt rename to pump/virtual/src/main/java/info/nightscout/pump/virtual/events/EventVirtualPumpUpdateGui.kt index 55457db925..4bb49eb4fb 100644 --- a/plugins/main/src/main/java/info/nightscout/plugins/pump/virtual/events/EventVirtualPumpUpdateGui.kt +++ b/pump/virtual/src/main/java/info/nightscout/pump/virtual/events/EventVirtualPumpUpdateGui.kt @@ -1,4 +1,4 @@ -package info.nightscout.plugins.pump.virtual.events +package info.nightscout.pump.virtual.events import info.nightscout.rx.events.EventUpdateGui diff --git a/plugins/main/src/main/java/info/nightscout/plugins/extensions/PumpEnactResultExtension.kt b/pump/virtual/src/main/java/info/nightscout/pump/virtual/extensions/PumpEnactResultExtension.kt similarity index 97% rename from plugins/main/src/main/java/info/nightscout/plugins/extensions/PumpEnactResultExtension.kt rename to pump/virtual/src/main/java/info/nightscout/pump/virtual/extensions/PumpEnactResultExtension.kt index 145156340c..664fdea6b2 100644 --- a/plugins/main/src/main/java/info/nightscout/plugins/extensions/PumpEnactResultExtension.kt +++ b/pump/virtual/src/main/java/info/nightscout/pump/virtual/extensions/PumpEnactResultExtension.kt @@ -1,4 +1,4 @@ -package info.nightscout.plugins.extensions +package info.nightscout.pump.virtual.extensions import info.nightscout.interfaces.pump.PumpEnactResult import info.nightscout.shared.interfaces.ResourceHelper diff --git a/plugins/main/src/main/res/layout/virtual_pump_fragment.xml b/pump/virtual/src/main/res/layout/virtual_pump_fragment.xml similarity index 99% rename from plugins/main/src/main/res/layout/virtual_pump_fragment.xml rename to pump/virtual/src/main/res/layout/virtual_pump_fragment.xml index 33d875cf98..f961d691e3 100644 --- a/plugins/main/src/main/res/layout/virtual_pump_fragment.xml +++ b/pump/virtual/src/main/res/layout/virtual_pump_fragment.xml @@ -2,7 +2,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - tools:context=".pump.virtual.VirtualPumpFragment"> + tools:context=".VirtualPumpFragment"> + + + Generic AAPS + MDI + Accu-Chek Combo + Accu-Chek Spirit + Accu-Chek Insight + Accu-Chek Solo + Animas Ping + Animas Vibe + Cellnovo + DanaR + DanaR Korean + DanaRS + DanaRv2 + DanaI + Diaconn G8 + Eoflow Eopatch2 + Medtronic 512/712 + Medtronic 515/715 + Medtronic 522/722 + Medtronic 523/723 (Revel) + Medtronic 554/754 (Veo) + Medtronic 640G + Omnipod Dash + Omnipod Eros + Tandem t:slim + Tandem t:flex + Tandem t:slim G4 + Tandem t:slim X2 + YpsoPump + + + \ No newline at end of file diff --git a/pump/virtual/src/main/res/values/strings.xml b/pump/virtual/src/main/res/values/strings.xml new file mode 100644 index 0000000000..3535a191cc --- /dev/null +++ b/pump/virtual/src/main/res/values/strings.xml @@ -0,0 +1,13 @@ + + + + Virtual Pump Type + Pump Definition + Bolus: Step=%1$s\nExtended Bolus: [Step=%2$s, Duration=%3$smin-%4$sh]\nBasal: Step=%5$s\nTBR: %6$s (by %7$s), Duration=%8$smin-%9$sh\n%10$s + + VPUMP + Pump integration for pumps which don\'t have any driver yet (Open Loop) + VIRTUAL PUMP + Virtual pump settings + + diff --git a/plugins/main/src/main/res/xml/pref_virtual_pump.xml b/pump/virtual/src/main/res/xml/pref_virtual_pump.xml similarity index 100% rename from plugins/main/src/main/res/xml/pref_virtual_pump.xml rename to pump/virtual/src/main/res/xml/pref_virtual_pump.xml diff --git a/pump/virtual/src/test/java/info/nightscout/androidaps/TestBase.kt b/pump/virtual/src/test/java/info/nightscout/androidaps/TestBase.kt new file mode 100644 index 0000000000..4fd2aef548 --- /dev/null +++ b/pump/virtual/src/test/java/info/nightscout/androidaps/TestBase.kt @@ -0,0 +1,37 @@ +package info.nightscout.androidaps + +import info.nightscout.rx.AapsSchedulers +import info.nightscout.rx.TestAapsSchedulers +import info.nightscout.rx.logging.AAPSLoggerTest +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.extension.ExtendWith +import org.mockito.Mockito +import org.mockito.junit.jupiter.MockitoExtension +import org.mockito.junit.jupiter.MockitoSettings +import org.mockito.quality.Strictness +import java.util.Locale + +@ExtendWith(MockitoExtension::class) +@MockitoSettings(strictness = Strictness.LENIENT) +open class TestBase { + + val aapsLogger = AAPSLoggerTest() + val aapsSchedulers: AapsSchedulers = TestAapsSchedulers() + + @BeforeEach + fun setupLocale() { + Locale.setDefault(Locale.ENGLISH) + System.setProperty("disableFirebase", "true") + } + + // Workaround for Kotlin nullability. + // https://medium.com/@elye.project/befriending-kotlin-and-mockito-1c2e7b0ef791 + // https://stackoverflow.com/questions/30305217/is-it-possible-to-use-mockito-in-kotlin + fun anyObject(): T { + Mockito.any() + return uninitialized() + } + + @Suppress("Unchecked_Cast") + fun uninitialized(): T = null as T +} \ No newline at end of file diff --git a/plugins/main/src/test/java/info/nightscout/plugins/pump/virtual/VirtualPumpPluginUTest.kt b/pump/virtual/src/test/java/info/nightscout/pump/virtual/VirtualPumpPluginUTest.kt similarity index 87% rename from plugins/main/src/test/java/info/nightscout/plugins/pump/virtual/VirtualPumpPluginUTest.kt rename to pump/virtual/src/test/java/info/nightscout/pump/virtual/VirtualPumpPluginUTest.kt index 7cc6f28978..872bb7c8eb 100644 --- a/plugins/main/src/test/java/info/nightscout/plugins/pump/virtual/VirtualPumpPluginUTest.kt +++ b/pump/virtual/src/test/java/info/nightscout/pump/virtual/VirtualPumpPluginUTest.kt @@ -1,4 +1,4 @@ -package info.nightscout.plugins.pump.virtual +package info.nightscout.pump.virtual import dagger.android.AndroidInjector import info.nightscout.androidaps.TestBase @@ -13,7 +13,7 @@ import info.nightscout.rx.bus.RxBus import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.utils.DateUtil -import org.junit.Assert +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.Mock @@ -32,7 +32,7 @@ class VirtualPumpPluginUTest : TestBase() { @Mock lateinit var pumpSync: PumpSync @Mock lateinit var config: Config - lateinit var virtualPumpPlugin: VirtualPumpPlugin + private lateinit var virtualPumpPlugin: VirtualPumpPlugin @BeforeEach fun prepareMocks() { @@ -43,7 +43,7 @@ class VirtualPumpPluginUTest : TestBase() { fun refreshConfiguration() { `when`(sp.getString(info.nightscout.core.utils.R.string.key_virtualpump_type, "Generic AAPS")).thenReturn("Accu-Chek Combo") virtualPumpPlugin.refreshConfiguration() - Assert.assertEquals(PumpType.ACCU_CHEK_COMBO, virtualPumpPlugin.pumpType) + Assertions.assertEquals(PumpType.ACCU_CHEK_COMBO, virtualPumpPlugin.pumpType) } @Test @@ -52,6 +52,6 @@ class VirtualPumpPluginUTest : TestBase() { virtualPumpPlugin.refreshConfiguration() `when`(sp.getString(info.nightscout.core.utils.R.string.key_virtualpump_type, "Generic AAPS")).thenReturn("Accu-Chek Combo") virtualPumpPlugin.refreshConfiguration() - Assert.assertEquals(PumpType.ACCU_CHEK_COMBO, virtualPumpPlugin.pumpType) + Assertions.assertEquals(PumpType.ACCU_CHEK_COMBO, virtualPumpPlugin.pumpType) } } \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index f47c3e1f04..dae8b065c8 100644 --- a/settings.gradle +++ b/settings.gradle @@ -40,5 +40,6 @@ include ':pump:omnipod-dash' include ':pump:pump-common' include ':pump:pump-core' include ':pump:rileylink' +include ':pump:virtual' include ':plugins:sync' include ':workflow'