hide insulin plugin in NSClient mode

This commit is contained in:
Milos Kozak 2021-11-29 17:26:29 +01:00
parent 3739db489f
commit 3ee1a3a9d8
10 changed files with 49 additions and 30 deletions

View file

@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.insulin
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.interfaces.Config
import info.nightscout.androidaps.interfaces.Insulin import info.nightscout.androidaps.interfaces.Insulin
import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
@ -16,8 +17,10 @@ class InsulinLyumjevPlugin @Inject constructor(
injector: HasAndroidInjector, injector: HasAndroidInjector,
rh: ResourceHelper, rh: ResourceHelper,
profileFunction: ProfileFunction, profileFunction: ProfileFunction,
rxBus: RxBus, aapsLogger: AAPSLogger rxBus: RxBus,
) : InsulinOrefBasePlugin(injector, rh, profileFunction, rxBus, aapsLogger) { aapsLogger: AAPSLogger,
config: Config
) : InsulinOrefBasePlugin(injector, rh, profileFunction, rxBus, aapsLogger, config) {
override val id get(): Insulin.InsulinType = Insulin.InsulinType.OREF_LYUMJEV override val id get(): Insulin.InsulinType = Insulin.InsulinType.OREF_LYUMJEV
override val friendlyName get(): String = rh.gs(R.string.lyumjev) override val friendlyName get(): String = rh.gs(R.string.lyumjev)

View file

@ -5,11 +5,7 @@ import info.nightscout.androidaps.R
import info.nightscout.androidaps.data.Iob import info.nightscout.androidaps.data.Iob
import info.nightscout.androidaps.database.embedments.InsulinConfiguration import info.nightscout.androidaps.database.embedments.InsulinConfiguration
import info.nightscout.androidaps.database.entities.Bolus import info.nightscout.androidaps.database.entities.Bolus
import info.nightscout.androidaps.interfaces.Insulin import info.nightscout.androidaps.interfaces.*
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.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
@ -29,13 +25,17 @@ abstract class InsulinOrefBasePlugin(
injector: HasAndroidInjector, injector: HasAndroidInjector,
rh: ResourceHelper, rh: ResourceHelper,
val profileFunction: ProfileFunction, val profileFunction: ProfileFunction,
val rxBus: RxBus, aapsLogger: AAPSLogger val rxBus: RxBus,
) : PluginBase(PluginDescription() aapsLogger: AAPSLogger,
.mainType(PluginType.INSULIN) config: Config
.fragmentClass(InsulinFragment::class.java.name) ) : PluginBase(
.pluginIcon(R.drawable.ic_insulin) PluginDescription()
.shortName(R.string.insulin_shortname) .mainType(PluginType.INSULIN)
.visibleByDefault(false), .fragmentClass(InsulinFragment::class.java.name)
.pluginIcon(R.drawable.ic_insulin)
.shortName(R.string.insulin_shortname)
.visibleByDefault(false)
.neverVisible(config.NSCLIENT),
aapsLogger, rh, injector aapsLogger, rh, injector
), Insulin { ), Insulin {

View file

@ -2,12 +2,13 @@ package info.nightscout.androidaps.plugins.insulin
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R 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.Insulin
import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.plugins.bus.RxBus 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.resources.ResourceHelper
import info.nightscout.androidaps.utils.sharedPreferences.SP import info.nightscout.androidaps.utils.sharedPreferences.SP
import org.json.JSONObject import org.json.JSONObject
@ -23,8 +24,10 @@ class InsulinOrefFreePeakPlugin @Inject constructor(
private val sp: SP, private val sp: SP,
rh: ResourceHelper, rh: ResourceHelper,
profileFunction: ProfileFunction, profileFunction: ProfileFunction,
rxBus: RxBus, aapsLogger: AAPSLogger rxBus: RxBus,
) : InsulinOrefBasePlugin(injector, rh, profileFunction, rxBus, aapsLogger) { aapsLogger: AAPSLogger,
config: Config
) : InsulinOrefBasePlugin(injector, rh, profileFunction, rxBus, aapsLogger, config) {
override val id get(): Insulin.InsulinType = Insulin.InsulinType.OREF_FREE_PEAK 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 configuration(): JSONObject = JSONObject().putInt(R.string.key_insulin_oref_peak, sp, rh)
override fun applyConfiguration(configuration: JSONObject) { 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 { override fun commentStandardText(): String {

View file

@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.insulin
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.interfaces.Config
import info.nightscout.androidaps.interfaces.Insulin import info.nightscout.androidaps.interfaces.Insulin
import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
@ -19,8 +20,10 @@ class InsulinOrefRapidActingPlugin @Inject constructor(
injector: HasAndroidInjector, injector: HasAndroidInjector,
rh: ResourceHelper, rh: ResourceHelper,
profileFunction: ProfileFunction, profileFunction: ProfileFunction,
rxBus: RxBus, aapsLogger: AAPSLogger rxBus: RxBus,
) : InsulinOrefBasePlugin(injector, rh, profileFunction, rxBus, aapsLogger) { aapsLogger: AAPSLogger,
config: Config
) : InsulinOrefBasePlugin(injector, rh, profileFunction, rxBus, aapsLogger, config) {
override val id get(): Insulin.InsulinType = Insulin.InsulinType.OREF_RAPID_ACTING override val id get(): Insulin.InsulinType = Insulin.InsulinType.OREF_RAPID_ACTING
override val friendlyName get(): String = rh.gs(R.string.rapid_acting_oref) override val friendlyName get(): String = rh.gs(R.string.rapid_acting_oref)

View file

@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.insulin
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.interfaces.Config
import info.nightscout.androidaps.interfaces.Insulin import info.nightscout.androidaps.interfaces.Insulin
import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
@ -19,8 +20,10 @@ class InsulinOrefUltraRapidActingPlugin @Inject constructor(
injector: HasAndroidInjector, injector: HasAndroidInjector,
rh: ResourceHelper, rh: ResourceHelper,
profileFunction: ProfileFunction, profileFunction: ProfileFunction,
rxBus: RxBus, aapsLogger: AAPSLogger rxBus: RxBus,
) : InsulinOrefBasePlugin(injector, rh, profileFunction, rxBus, aapsLogger) { 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 id get(): Insulin.InsulinType = Insulin.InsulinType.OREF_ULTRA_RAPID_ACTING
override val friendlyName get(): String = rh.gs(R.string.ultrarapid_oref) override val friendlyName get(): String = rh.gs(R.string.ultrarapid_oref)

View file

@ -7,6 +7,7 @@ import info.nightscout.androidaps.interfaces.Insulin
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.utils.buildHelper.ConfigImpl
import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.resources.ResourceHelper
import org.junit.Assert.assertEquals import org.junit.Assert.assertEquals
import org.junit.Before import org.junit.Before
@ -37,7 +38,7 @@ class InsulinLyumjevPluginTest {
@Before @Before
fun setup() { fun setup() {
sut = InsulinLyumjevPlugin(injector, rh, profileFunction, rxBus, aapsLogger) sut = InsulinLyumjevPlugin(injector, rh, profileFunction, rxBus, aapsLogger, ConfigImpl())
} }
@Test @Test

View file

@ -12,6 +12,7 @@ import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.insulin.InsulinOrefBasePlugin.Companion.MIN_DIA import info.nightscout.androidaps.plugins.insulin.InsulinOrefBasePlugin.Companion.MIN_DIA
import info.nightscout.androidaps.utils.DefaultValueHelper import info.nightscout.androidaps.utils.DefaultValueHelper
import info.nightscout.androidaps.utils.buildHelper.ConfigImpl
import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.resources.ResourceHelper
import org.json.JSONObject import org.json.JSONObject
import org.junit.Assert import org.junit.Assert
@ -35,7 +36,7 @@ class InsulinOrefBasePluginTest {
rxBus: RxBus, rxBus: RxBus,
aapsLogger: AAPSLogger aapsLogger: AAPSLogger
) : InsulinOrefBasePlugin( ) : InsulinOrefBasePlugin(
injector, rh, profileFunction, rxBus, aapsLogger injector, rh, profileFunction, rxBus, aapsLogger, ConfigImpl()
) { ) {
override fun sendShortDiaNotification(dia: Double) { override fun sendShortDiaNotification(dia: Double) {

View file

@ -2,11 +2,12 @@ package info.nightscout.androidaps.plugins.insulin
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.TestBase
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.TestBase
import info.nightscout.androidaps.interfaces.Insulin import info.nightscout.androidaps.interfaces.Insulin
import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.interfaces.ProfileFunction 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.resources.ResourceHelper
import info.nightscout.androidaps.utils.sharedPreferences.SP import info.nightscout.androidaps.utils.sharedPreferences.SP
import org.junit.Assert.assertEquals import org.junit.Assert.assertEquals
@ -43,7 +44,9 @@ class InsulinOrefFreePeakPluginTest : TestBase() {
rh, rh,
profileFunction, profileFunction,
rxBus, rxBus,
aapsLogger) aapsLogger,
ConfigImpl()
)
} }
@Test @Test

View file

@ -7,6 +7,7 @@ import info.nightscout.androidaps.interfaces.Insulin
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.utils.buildHelper.ConfigImpl
import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.resources.ResourceHelper
import org.junit.Assert.assertEquals import org.junit.Assert.assertEquals
import org.junit.Before import org.junit.Before
@ -37,7 +38,7 @@ class InsulinOrefRapidActingPluginTest {
@Before @Before
fun setup() { fun setup() {
sut = InsulinOrefRapidActingPlugin(injector, rh, profileFunction, rxBus, aapsLogger) sut = InsulinOrefRapidActingPlugin(injector, rh, profileFunction, rxBus, aapsLogger, ConfigImpl())
} }
@Test @Test

View file

@ -7,6 +7,7 @@ import info.nightscout.androidaps.interfaces.Insulin
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.utils.buildHelper.ConfigImpl
import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.resources.ResourceHelper
import org.junit.Assert.assertEquals import org.junit.Assert.assertEquals
import org.junit.Before import org.junit.Before
@ -37,7 +38,7 @@ class InsulinOrefUltraRapidActingPluginTest {
@Before @Before
fun setup() { fun setup() {
sut = InsulinOrefUltraRapidActingPlugin(injector, rh, profileFunction, rxBus, aapsLogger) sut = InsulinOrefUltraRapidActingPlugin(injector, rh, profileFunction, rxBus, aapsLogger, ConfigImpl())
} }
@Test @Test