From 3ee1a3a9d806df84e0e559af40df1512586a085b Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 29 Nov 2021 17:26:29 +0100 Subject: [PATCH] hide insulin plugin in NSClient mode --- .../plugins/insulin/InsulinLyumjevPlugin.kt | 7 ++++-- .../plugins/insulin/InsulinOrefBasePlugin.kt | 24 +++++++++---------- .../insulin/InsulinOrefFreePeakPlugin.kt | 13 ++++++---- .../insulin/InsulinOrefRapidActingPlugin.kt | 7 ++++-- .../InsulinOrefUltraRapidActingPlugin.kt | 7 ++++-- .../insulin/InsulinLyumjevPluginTest.kt | 3 ++- .../insulin/InsulinOrefBasePluginTest.kt | 3 ++- .../insulin/InsulinOrefFreePeakPluginTest.kt | 9 ++++--- .../InsulinOrefRapidActingPluginTest.kt | 3 ++- .../InsulinOrefUltraRapidActingPluginTest.kt | 3 ++- 10 files changed, 49 insertions(+), 30 deletions(-) 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 index a2e0b3c2ec..6c34a2b0a6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinLyumjevPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinLyumjevPlugin.kt @@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.insulin import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R +import info.nightscout.androidaps.interfaces.Config import info.nightscout.androidaps.interfaces.Insulin import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.logging.AAPSLogger @@ -16,8 +17,10 @@ class InsulinLyumjevPlugin @Inject constructor( injector: HasAndroidInjector, rh: ResourceHelper, profileFunction: ProfileFunction, - rxBus: RxBus, aapsLogger: AAPSLogger -) : InsulinOrefBasePlugin(injector, rh, profileFunction, rxBus, aapsLogger) { + rxBus: RxBus, + aapsLogger: AAPSLogger, + config: Config +) : InsulinOrefBasePlugin(injector, rh, profileFunction, rxBus, aapsLogger, config) { override val id get(): Insulin.InsulinType = Insulin.InsulinType.OREF_LYUMJEV override val friendlyName get(): String = rh.gs(R.string.lyumjev) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefBasePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefBasePlugin.kt index e33bcacc93..37319ad8c0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefBasePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefBasePlugin.kt @@ -5,11 +5,7 @@ import info.nightscout.androidaps.R import info.nightscout.androidaps.data.Iob import info.nightscout.androidaps.database.embedments.InsulinConfiguration import info.nightscout.androidaps.database.entities.Bolus -import info.nightscout.androidaps.interfaces.Insulin -import info.nightscout.androidaps.interfaces.PluginBase -import info.nightscout.androidaps.interfaces.PluginDescription -import info.nightscout.androidaps.interfaces.PluginType -import info.nightscout.androidaps.interfaces.ProfileFunction +import info.nightscout.androidaps.interfaces.* import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification @@ -29,13 +25,17 @@ abstract class InsulinOrefBasePlugin( injector: HasAndroidInjector, rh: ResourceHelper, val profileFunction: ProfileFunction, - val rxBus: RxBus, aapsLogger: AAPSLogger -) : PluginBase(PluginDescription() - .mainType(PluginType.INSULIN) - .fragmentClass(InsulinFragment::class.java.name) - .pluginIcon(R.drawable.ic_insulin) - .shortName(R.string.insulin_shortname) - .visibleByDefault(false), + val rxBus: RxBus, + aapsLogger: AAPSLogger, + config: Config +) : PluginBase( + PluginDescription() + .mainType(PluginType.INSULIN) + .fragmentClass(InsulinFragment::class.java.name) + .pluginIcon(R.drawable.ic_insulin) + .shortName(R.string.insulin_shortname) + .visibleByDefault(false) + .neverVisible(config.NSCLIENT), aapsLogger, rh, injector ), Insulin { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefFreePeakPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefFreePeakPlugin.kt index 5a14fed8f9..60647d165e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefFreePeakPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefFreePeakPlugin.kt @@ -2,12 +2,13 @@ package info.nightscout.androidaps.plugins.insulin import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R +import info.nightscout.androidaps.extensions.putInt +import info.nightscout.androidaps.extensions.storeInt +import info.nightscout.androidaps.interfaces.Config import info.nightscout.androidaps.interfaces.Insulin import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBus -import info.nightscout.androidaps.extensions.storeInt -import info.nightscout.androidaps.extensions.putInt import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP import org.json.JSONObject @@ -23,8 +24,10 @@ class InsulinOrefFreePeakPlugin @Inject constructor( private val sp: SP, rh: ResourceHelper, profileFunction: ProfileFunction, - rxBus: RxBus, aapsLogger: AAPSLogger -) : InsulinOrefBasePlugin(injector, rh, profileFunction, rxBus, aapsLogger) { + rxBus: RxBus, + aapsLogger: AAPSLogger, + config: Config +) : InsulinOrefBasePlugin(injector, rh, profileFunction, rxBus, aapsLogger, config) { override val id get(): Insulin.InsulinType = Insulin.InsulinType.OREF_FREE_PEAK @@ -32,7 +35,7 @@ class InsulinOrefFreePeakPlugin @Inject constructor( override fun configuration(): JSONObject = JSONObject().putInt(R.string.key_insulin_oref_peak, sp, rh) override fun applyConfiguration(configuration: JSONObject) { - configuration.storeInt(R.string.key_insulin_oref_peak, sp, rh) + configuration.storeInt(R.string.key_insulin_oref_peak, sp, rh) } override fun commentStandardText(): String { 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 9ec79e428c..41e8b68167 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 @@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.insulin import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R +import info.nightscout.androidaps.interfaces.Config import info.nightscout.androidaps.interfaces.Insulin import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.logging.AAPSLogger @@ -19,8 +20,10 @@ class InsulinOrefRapidActingPlugin @Inject constructor( injector: HasAndroidInjector, rh: ResourceHelper, profileFunction: ProfileFunction, - rxBus: RxBus, aapsLogger: AAPSLogger -) : InsulinOrefBasePlugin(injector, rh, profileFunction, rxBus, aapsLogger) { + rxBus: RxBus, + aapsLogger: AAPSLogger, + config: Config +) : InsulinOrefBasePlugin(injector, rh, profileFunction, rxBus, aapsLogger, config) { override val id get(): Insulin.InsulinType = Insulin.InsulinType.OREF_RAPID_ACTING override val friendlyName get(): String = rh.gs(R.string.rapid_acting_oref) 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 dfa800291b..adb632ef6f 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 @@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.insulin import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R +import info.nightscout.androidaps.interfaces.Config import info.nightscout.androidaps.interfaces.Insulin import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.logging.AAPSLogger @@ -19,8 +20,10 @@ class InsulinOrefUltraRapidActingPlugin @Inject constructor( injector: HasAndroidInjector, rh: ResourceHelper, profileFunction: ProfileFunction, - rxBus: RxBus, aapsLogger: AAPSLogger -) : InsulinOrefBasePlugin(injector, rh, profileFunction, rxBus, aapsLogger) { + rxBus: RxBus, + aapsLogger: AAPSLogger, + config: Config +) : InsulinOrefBasePlugin(injector, rh, profileFunction, rxBus, aapsLogger, config) { override val id get(): Insulin.InsulinType = Insulin.InsulinType.OREF_ULTRA_RAPID_ACTING override val friendlyName get(): String = rh.gs(R.string.ultrarapid_oref) 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 index 0fb0290810..60f77e37c9 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/insulin/InsulinLyumjevPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/insulin/InsulinLyumjevPluginTest.kt @@ -7,6 +7,7 @@ import info.nightscout.androidaps.interfaces.Insulin import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.interfaces.ProfileFunction +import info.nightscout.androidaps.utils.buildHelper.ConfigImpl import info.nightscout.androidaps.utils.resources.ResourceHelper import org.junit.Assert.assertEquals import org.junit.Before @@ -37,7 +38,7 @@ class InsulinLyumjevPluginTest { @Before fun setup() { - sut = InsulinLyumjevPlugin(injector, rh, profileFunction, rxBus, aapsLogger) + sut = InsulinLyumjevPlugin(injector, rh, profileFunction, rxBus, aapsLogger, ConfigImpl()) } @Test diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefBasePluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefBasePluginTest.kt index dcd01949cd..b6be2d882a 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefBasePluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefBasePluginTest.kt @@ -12,6 +12,7 @@ import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.insulin.InsulinOrefBasePlugin.Companion.MIN_DIA import info.nightscout.androidaps.utils.DefaultValueHelper +import info.nightscout.androidaps.utils.buildHelper.ConfigImpl import info.nightscout.androidaps.utils.resources.ResourceHelper import org.json.JSONObject import org.junit.Assert @@ -35,7 +36,7 @@ class InsulinOrefBasePluginTest { rxBus: RxBus, aapsLogger: AAPSLogger ) : InsulinOrefBasePlugin( - injector, rh, profileFunction, rxBus, aapsLogger + injector, rh, profileFunction, rxBus, aapsLogger, ConfigImpl() ) { override fun sendShortDiaNotification(dia: Double) { diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefFreePeakPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefFreePeakPluginTest.kt index dfe7937972..1b47bb36f2 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefFreePeakPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefFreePeakPluginTest.kt @@ -2,11 +2,12 @@ package info.nightscout.androidaps.plugins.insulin import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.R +import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.interfaces.Insulin -import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.interfaces.ProfileFunction +import info.nightscout.androidaps.plugins.bus.RxBus +import info.nightscout.androidaps.utils.buildHelper.ConfigImpl import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP import org.junit.Assert.assertEquals @@ -43,7 +44,9 @@ class InsulinOrefFreePeakPluginTest : TestBase() { rh, profileFunction, rxBus, - aapsLogger) + aapsLogger, + ConfigImpl() + ) } @Test diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefRapidActingPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefRapidActingPluginTest.kt index fcd6de648e..bbbde02c43 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefRapidActingPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefRapidActingPluginTest.kt @@ -7,6 +7,7 @@ import info.nightscout.androidaps.interfaces.Insulin import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.interfaces.ProfileFunction +import info.nightscout.androidaps.utils.buildHelper.ConfigImpl import info.nightscout.androidaps.utils.resources.ResourceHelper import org.junit.Assert.assertEquals import org.junit.Before @@ -37,7 +38,7 @@ class InsulinOrefRapidActingPluginTest { @Before fun setup() { - sut = InsulinOrefRapidActingPlugin(injector, rh, profileFunction, rxBus, aapsLogger) + sut = InsulinOrefRapidActingPlugin(injector, rh, profileFunction, rxBus, aapsLogger, ConfigImpl()) } @Test diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefUltraRapidActingPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefUltraRapidActingPluginTest.kt index 88ecff887f..c86183e09d 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefUltraRapidActingPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/insulin/InsulinOrefUltraRapidActingPluginTest.kt @@ -7,6 +7,7 @@ import info.nightscout.androidaps.interfaces.Insulin import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.interfaces.ProfileFunction +import info.nightscout.androidaps.utils.buildHelper.ConfigImpl import info.nightscout.androidaps.utils.resources.ResourceHelper import org.junit.Assert.assertEquals import org.junit.Before @@ -37,7 +38,7 @@ class InsulinOrefUltraRapidActingPluginTest { @Before fun setup() { - sut = InsulinOrefUltraRapidActingPlugin(injector, rh, profileFunction, rxBus, aapsLogger) + sut = InsulinOrefUltraRapidActingPlugin(injector, rh, profileFunction, rxBus, aapsLogger, ConfigImpl()) } @Test