diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/PluginsModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/PluginsModule.kt index 75c834977a..892c9c36a8 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/PluginsModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/PluginsModule.kt @@ -31,6 +31,7 @@ import info.nightscout.androidaps.plugins.general.persistentNotification.Persist import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin import info.nightscout.androidaps.plugins.general.wear.WearPlugin import info.nightscout.androidaps.plugins.general.xdripStatusline.StatusLinePlugin +import info.nightscout.androidaps.plugins.insulin.InsulinLyumjevPlugin import info.nightscout.androidaps.plugins.insulin.InsulinOrefFreePeakPlugin import info.nightscout.androidaps.plugins.insulin.InsulinOrefRapidActingPlugin import info.nightscout.androidaps.plugins.insulin.InsulinOrefUltraRapidActingPlugin @@ -82,6 +83,12 @@ abstract class PluginsModule { @IntKey(40) abstract fun bindInsulinOrefUltraRapidActingPlugin(plugin: InsulinOrefUltraRapidActingPlugin): PluginBase + @Binds + @AllConfigs + @IntoMap + @IntKey(42) + abstract fun bindInsulinLyumjevPlugin(plugin: InsulinLyumjevPlugin): PluginBase + @Binds @AllConfigs @IntoMap diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinLyumjevPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinLyumjevPlugin.kt new file mode 100644 index 0000000000..b5fa0fea3d --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinLyumjevPlugin.kt @@ -0,0 +1,35 @@ +package info.nightscout.androidaps.plugins.insulin + +import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.R +import info.nightscout.androidaps.interfaces.InsulinInterface +import info.nightscout.androidaps.logging.AAPSLogger +import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.interfaces.ProfileFunction +import info.nightscout.androidaps.utils.resources.ResourceHelper +import javax.inject.Inject +import javax.inject.Singleton + +@Singleton +class InsulinLyumjevPlugin @Inject constructor( + injector: HasAndroidInjector, + resourceHelper: ResourceHelper, + profileFunction: ProfileFunction, + rxBus: RxBusWrapper, aapsLogger: AAPSLogger +) : InsulinOrefBasePlugin(injector, resourceHelper, profileFunction, rxBus, aapsLogger) { + + + override fun getId(): Int = InsulinInterface.OREF_LYUMJEV + + override fun getFriendlyName(): String = resourceHelper.gs(R.string.lyumjev) + + override fun commentStandardText(): String = resourceHelper.gs(R.string.lyumjev) + + override val peak = 45 + + init { + pluginDescription + .pluginName(R.string.lyumjev) + .description(R.string.description_insulin_lyumjev) + } +} \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefRapidActingPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefRapidActingPlugin.kt index 770e7f1f91..a0241ff9c9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefRapidActingPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefRapidActingPlugin.kt @@ -41,5 +41,6 @@ class InsulinOrefRapidActingPlugin @Inject constructor( .pluginName(R.string.rapid_acting_oref) .description(R.string.description_insulin_rapid) .setDefault() + .enableByDefault(true) } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefUltraRapidActingPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefUltraRapidActingPlugin.kt index 60f07c3203..a793c47e89 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefUltraRapidActingPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefUltraRapidActingPlugin.kt @@ -34,6 +34,5 @@ class InsulinOrefUltraRapidActingPlugin @Inject constructor( pluginDescription .pluginName(R.string.ultrarapid_oref) .description(R.string.description_insulin_ultra_rapid) - .enableByDefault(true) } } \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 05014ba225..69d711c5bc 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -45,6 +45,7 @@ Displays the food presets defined in Nightscout Insulin preset for Humalog and NovoRapid / NovoLog Insulin preset for Fiasp + Insulin preset for Lyumjev Allows you to define the peak of the insulin activity and should only be used by advanced users Activate or deactivate the implementation triggering the loop. Synchronizes your data with Nightscout @@ -630,6 +631,7 @@ Free-Peak Oref Rapid-Acting Oref Ultra-Rapid Oref + Lyumjev DIA of %1$f too short - using %2$f instead! Activate profile INVALID diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/insulin/InsulinLyumjevPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/insulin/InsulinLyumjevPluginTest.kt new file mode 100644 index 0000000000..01ea1f9b8a --- /dev/null +++ b/app/src/test/java/info/nightscout/androidaps/plugins/insulin/InsulinLyumjevPluginTest.kt @@ -0,0 +1,65 @@ +package info.nightscout.androidaps.plugins.insulin + +import dagger.android.AndroidInjector +import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.R +import info.nightscout.androidaps.interfaces.InsulinInterface +import info.nightscout.androidaps.logging.AAPSLogger +import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.interfaces.ProfileFunction +import info.nightscout.androidaps.utils.resources.ResourceHelper +import org.junit.Assert.assertEquals +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.mockito.ArgumentMatchers.eq +import org.mockito.Mock +import org.mockito.Mockito.`when` +import org.mockito.junit.MockitoJUnit +import org.mockito.junit.MockitoRule + +class InsulinLyumjevPluginTest { + + @get:Rule + val mockitoRule: MockitoRule = MockitoJUnit.rule() + + private lateinit var sut: InsulinLyumjevPlugin + + @Mock lateinit var resourceHelper: ResourceHelper + @Mock lateinit var rxBus: RxBusWrapper + @Mock lateinit var profileFunction: ProfileFunction + @Mock lateinit var aapsLogger: AAPSLogger + + private var injector: HasAndroidInjector = HasAndroidInjector { + AndroidInjector { + } + } + + @Before + fun setup() { + sut = InsulinLyumjevPlugin(injector, resourceHelper, profileFunction, rxBus, aapsLogger) + } + + @Test + fun `simple peak test`() { + assertEquals(45, sut.peak) + } + + @Test + fun getIdTest() { + assertEquals(InsulinInterface.OREF_LYUMJEV, sut.id) + } + + @Test + fun commentStandardTextTest() { + `when`(resourceHelper.gs(eq(R.string.lyumjev))).thenReturn("Lyumjev") + assertEquals("Lyumjev", sut.commentStandardText()) + } + + @Test + fun getFriendlyNameTest() { + `when`(resourceHelper.gs(eq(R.string.lyumjev))).thenReturn("Lyumjev") + assertEquals("Lyumjev", sut.friendlyName) + } + +} \ No newline at end of file diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/InsulinInterface.java b/core/src/main/java/info/nightscout/androidaps/interfaces/InsulinInterface.java index d5e8ab399d..caeb77de9a 100644 --- a/core/src/main/java/info/nightscout/androidaps/interfaces/InsulinInterface.java +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/InsulinInterface.java @@ -13,6 +13,7 @@ public interface InsulinInterface { int OREF_RAPID_ACTING = 2; int OREF_ULTRA_RAPID_ACTING = 3; int OREF_FREE_PEAK = 4; + int OREF_LYUMJEV = 5; int getId();