extract interfaces off ConfigBuilder extra functionality

This commit is contained in:
AdrianLxM 2020-01-07 10:14:12 +01:00
parent 3a77fb70fe
commit f6fe84808e
13 changed files with 115 additions and 73 deletions

View file

@ -7,9 +7,9 @@ import com.google.firebase.database.FirebaseDatabase
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.data.defaultProfile.DefaultProfile import info.nightscout.androidaps.data.defaultProfile.DefaultProfile
import info.nightscout.androidaps.dialogs.ProfileViewerDialog import info.nightscout.androidaps.dialogs.ProfileViewerDialog
import info.nightscout.androidaps.interfaces.ActivePluginProvider
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
import info.nightscout.androidaps.utils.* import info.nightscout.androidaps.utils.*
import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.resources.ResourceHelper
@ -21,7 +21,7 @@ import javax.inject.Inject
class SurveyActivity : NoSplashAppCompatActivity() { class SurveyActivity : NoSplashAppCompatActivity() {
@Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var resourceHelper: ResourceHelper
@Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin @Inject lateinit var activePluginProvider: ActivePluginProvider
@Inject lateinit var tddCalculator: TddCalculator @Inject lateinit var tddCalculator: TddCalculator
@Inject lateinit var tirCalculator: TirCalculator @Inject lateinit var tirCalculator: TirCalculator
@Inject lateinit var profileFunction: ProfileFunction @Inject lateinit var profileFunction: ProfileFunction
@ -33,7 +33,7 @@ class SurveyActivity : NoSplashAppCompatActivity() {
survey_id.text = InstanceId.instanceId() survey_id.text = InstanceId.instanceId()
val profileStore = configBuilderPlugin.activeProfileInterface.profile val profileStore = activePluginProvider.activeProfileInterface.profile
val profileList = profileStore?.getProfileList() ?: return val profileList = profileStore?.getProfileList() ?: return
survey_spinner.adapter = ArrayAdapter(this, R.layout.spinner_centered, profileList) survey_spinner.adapter = ArrayAdapter(this, R.layout.spinner_centered, profileList)

View file

@ -9,6 +9,8 @@ import dagger.android.ContributesAndroidInjector
import info.nightscout.androidaps.BuildConfig import info.nightscout.androidaps.BuildConfig
import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.db.BgReading import info.nightscout.androidaps.db.BgReading
import info.nightscout.androidaps.interfaces.ActivePluginProvider
import info.nightscout.androidaps.interfaces.CommandQueueProvider
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.AAPSLoggerDebug import info.nightscout.androidaps.logging.AAPSLoggerDebug
import info.nightscout.androidaps.logging.AAPSLoggerProduction import info.nightscout.androidaps.logging.AAPSLoggerProduction
@ -138,5 +140,10 @@ open class AppModule {
@ContributesAndroidInjector fun loggerQuickWizardEntry(): QuickWizardEntry @ContributesAndroidInjector fun loggerQuickWizardEntry(): QuickWizardEntry
@Binds fun bindContext(mainApp: MainApp): Context @Binds fun bindContext(mainApp: MainApp): Context
@Binds fun bindActivePluginProvider(configBuilderPlugin: ConfigBuilderPlugin) : ActivePluginProvider
@Binds fun bindCommandQueueProvider(configBuilderPlugin: ConfigBuilderPlugin) : CommandQueueProvider
} }
} }

View file

@ -0,0 +1,23 @@
package info.nightscout.androidaps.interfaces;
import androidx.annotation.Nullable;
import org.jetbrains.annotations.NotNull;
/**
* Created by adrian on 2020-01-07.
*/
public interface ActivePluginProvider {
@Nullable BgSourceInterface getActiveBgSource();
@NotNull ProfileInterface getActiveProfileInterface();
@Nullable InsulinInterface getActiveInsulin();
@Nullable APSInterface getActiveAPS();
@Nullable PumpInterface getActivePump();
@Nullable SensitivityInterface getActiveSensitivity();
}

View file

@ -0,0 +1,11 @@
package info.nightscout.androidaps.interfaces;
import info.nightscout.androidaps.queue.CommandQueue;
/**
* Created by adrian on 2020-01-07.
*/
public interface CommandQueueProvider {
CommandQueue getCommandQueue();
}

View file

@ -14,7 +14,9 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventAppInitialized; import info.nightscout.androidaps.events.EventAppInitialized;
import info.nightscout.androidaps.interfaces.APSInterface; import info.nightscout.androidaps.interfaces.APSInterface;
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
import info.nightscout.androidaps.interfaces.BgSourceInterface; import info.nightscout.androidaps.interfaces.BgSourceInterface;
import info.nightscout.androidaps.interfaces.CommandQueueProvider;
import info.nightscout.androidaps.interfaces.InsulinInterface; import info.nightscout.androidaps.interfaces.InsulinInterface;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginDescription;
@ -38,7 +40,7 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP;
* Created by mike on 05.08.2016. * Created by mike on 05.08.2016.
*/ */
@Singleton @Singleton
public class ConfigBuilderPlugin extends PluginBase { public class ConfigBuilderPlugin extends PluginBase implements ActivePluginProvider, CommandQueueProvider {
private static ConfigBuilderPlugin configBuilderPlugin; private static ConfigBuilderPlugin configBuilderPlugin;
private final SP sp; private final SP sp;
@ -244,37 +246,37 @@ public class ConfigBuilderPlugin extends PluginBase {
} }
} }
public CommandQueue getCommandQueue() { @Override public CommandQueue getCommandQueue() {
return commandQueue; return commandQueue;
} }
@Nullable @Override @Nullable
public BgSourceInterface getActiveBgSource() { public BgSourceInterface getActiveBgSource() {
return activeBgSource; return activeBgSource;
} }
@NotNull @Override @NotNull
public ProfileInterface getActiveProfileInterface() { public ProfileInterface getActiveProfileInterface() {
if (activeProfile != null) return activeProfile; if (activeProfile != null) return activeProfile;
else return localProfilePlugin.get(); else return localProfilePlugin.get();
} }
@Nullable @Override @Nullable
public InsulinInterface getActiveInsulin() { public InsulinInterface getActiveInsulin() {
return activeInsulin; return activeInsulin;
} }
@Nullable @Override @Nullable
public APSInterface getActiveAPS() { public APSInterface getActiveAPS() {
return activeAPS; return activeAPS;
} }
@Nullable @Override @Nullable
public PumpInterface getActivePump() { public PumpInterface getActivePump() {
return activePump; return activePump;
} }
@Nullable @Override @Nullable
public SensitivityInterface getActiveSensitivity() { public SensitivityInterface getActiveSensitivity() {
return activeSensitivity; return activeSensitivity;
} }

View file

@ -10,6 +10,7 @@ import androidx.appcompat.app.AppCompatActivity
import com.google.common.base.Optional import com.google.common.base.Optional
import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.interfaces.ActivePluginProvider
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
@ -37,7 +38,7 @@ abstract class Trigger(val mainApp: MainApp) {
@Inject lateinit var sp: SP @Inject lateinit var sp: SP
@Inject lateinit var locationDataContainer: LastLocationDataContainer @Inject lateinit var locationDataContainer: LastLocationDataContainer
@Inject lateinit var treatmentsPlugin: TreatmentsPlugin @Inject lateinit var treatmentsPlugin: TreatmentsPlugin
@Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin @Inject lateinit var activePluginProvider: ActivePluginProvider
@Inject lateinit var iobCobCalculatorPlugin: IobCobCalculatorPlugin @Inject lateinit var iobCobCalculatorPlugin: IobCobCalculatorPlugin
init { init {

View file

@ -30,7 +30,7 @@ class TriggerPumpLastConnection(mainApp: MainApp) : Trigger(mainApp) {
} }
override fun shouldRun(): Boolean { override fun shouldRun(): Boolean {
val lastConnection = configBuilderPlugin.activePump?.lastDataTime() ?: return false val lastConnection = activePluginProvider.activePump?.lastDataTime() ?: return false
if (lastConnection == 0L && comparator.value === Comparator.Compare.IS_NOT_AVAILABLE) { if (lastConnection == 0L && comparator.value === Comparator.Compare.IS_NOT_AVAILABLE) {
aapsLogger.debug(LTag.AUTOMATION, "Ready for execution: " + friendlyDescription()) aapsLogger.debug(LTag.AUTOMATION, "Ready for execution: " + friendlyDescription())
return true return true

View file

@ -16,6 +16,7 @@ import info.nightscout.androidaps.R
import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.data.Profile
import info.nightscout.androidaps.db.DatabaseHelper import info.nightscout.androidaps.db.DatabaseHelper
import info.nightscout.androidaps.events.* import info.nightscout.androidaps.events.*
import info.nightscout.androidaps.interfaces.ActivePluginProvider
import info.nightscout.androidaps.interfaces.PluginBase import info.nightscout.androidaps.interfaces.PluginBase
import info.nightscout.androidaps.interfaces.PluginDescription import info.nightscout.androidaps.interfaces.PluginDescription
import info.nightscout.androidaps.interfaces.PluginType import info.nightscout.androidaps.interfaces.PluginType
@ -41,7 +42,7 @@ class PersistentNotificationPlugin @Inject constructor(
var resourceHelper: ResourceHelper, var resourceHelper: ResourceHelper,
var profileFunction: ProfileFunction, var profileFunction: ProfileFunction,
var fabricPrivacy: FabricPrivacy, var fabricPrivacy: FabricPrivacy,
var configBuilderPlugin: ConfigBuilderPlugin, var activePlugins: ActivePluginProvider,
var treatmentsPlugin: TreatmentsPlugin, var treatmentsPlugin: TreatmentsPlugin,
var iobCobCalculatorPlugin: IobCobCalculatorPlugin, var iobCobCalculatorPlugin: IobCobCalculatorPlugin,
rxBus: RxBusWrapper, rxBus: RxBusWrapper,
@ -129,7 +130,7 @@ class PersistentNotificationPlugin @Inject constructor(
} }
private fun updateNotification() { private fun updateNotification() {
val pump = configBuilderPlugin.activePump ?: return val pump = activePlugins.activePump ?: return
var line1: String? var line1: String?
var line2: String? = null var line2: String? = null
var line3: String? = null var line3: String? = null

View file

@ -18,15 +18,11 @@ import info.nightscout.androidaps.db.Source
import info.nightscout.androidaps.db.TempTarget import info.nightscout.androidaps.db.TempTarget
import info.nightscout.androidaps.events.EventPreferenceChange import info.nightscout.androidaps.events.EventPreferenceChange
import info.nightscout.androidaps.events.EventRefreshOverview import info.nightscout.androidaps.events.EventRefreshOverview
import info.nightscout.androidaps.interfaces.Constraint 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.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
@ -59,7 +55,8 @@ class SmsCommunicatorPlugin @Inject constructor(
rxBus: RxBusWrapper, rxBus: RxBusWrapper,
private val profileFunction: ProfileFunction, private val profileFunction: ProfileFunction,
private val fabricPrivacy: FabricPrivacy, private val fabricPrivacy: FabricPrivacy,
private val configBuilderPlugin: ConfigBuilderPlugin, private val activePluginProvider: ActivePluginProvider,
private val commandQueueProvider: CommandQueueProvider,
private val treatmentsPlugin: TreatmentsPlugin, private val treatmentsPlugin: TreatmentsPlugin,
private val loopPlugin: LoopPlugin, private val loopPlugin: LoopPlugin,
private val iobCobCalculatorPlugin: IobCobCalculatorPlugin private val iobCobCalculatorPlugin: IobCobCalculatorPlugin
@ -200,7 +197,7 @@ class SmsCommunicatorPlugin @Inject constructor(
rxBus.send(EventSmsCommunicatorUpdateGui()) rxBus.send(EventSmsCommunicatorUpdateGui())
return return
} }
val pump = configBuilderPlugin.activePump ?: return val pump = activePluginProvider.activePump ?: return
messages.add(receivedSms) messages.add(receivedSms)
aapsLogger.debug(LTag.SMS, receivedSms.toString()) aapsLogger.debug(LTag.SMS, receivedSms.toString())
val splitted = receivedSms.text.split(Regex("\\s+")).toTypedArray() val splitted = receivedSms.text.split(Regex("\\s+")).toTypedArray()
@ -302,7 +299,7 @@ class SmsCommunicatorPlugin @Inject constructor(
"DISABLE", "STOP" -> { "DISABLE", "STOP" -> {
if (loopPlugin.isEnabled(PluginType.LOOP)) { if (loopPlugin.isEnabled(PluginType.LOOP)) {
loopPlugin.setPluginEnabled(PluginType.LOOP, false) loopPlugin.setPluginEnabled(PluginType.LOOP, false)
configBuilderPlugin.commandQueue.cancelTempBasal(true, object : Callback() { commandQueueProvider.commandQueue.cancelTempBasal(true, object : Callback() {
override fun run() { override fun run() {
rxBus.send(EventRefreshOverview("SMS_LOOP_STOP")) rxBus.send(EventRefreshOverview("SMS_LOOP_STOP"))
val replyText = resourceHelper.gs(R.string.smscommunicator_loophasbeendisabled) + " " + val replyText = resourceHelper.gs(R.string.smscommunicator_loophasbeendisabled) + " " +
@ -356,7 +353,7 @@ class SmsCommunicatorPlugin @Inject constructor(
receivedSms.processed = true receivedSms.processed = true
messageToConfirm = AuthRequest(this, resourceHelper, receivedSms, reply, passCode, object : SmsAction(duration) { messageToConfirm = AuthRequest(this, resourceHelper, receivedSms, reply, passCode, object : SmsAction(duration) {
override fun run() { override fun run() {
configBuilderPlugin.commandQueue.cancelTempBasal(true, object : Callback() { commandQueueProvider.commandQueue.cancelTempBasal(true, object : Callback() {
override fun run() { override fun run() {
if (result.success) { if (result.success) {
loopPlugin.suspendTo(System.currentTimeMillis() + anInteger() * 60L * 1000) loopPlugin.suspendTo(System.currentTimeMillis() + anInteger() * 60L * 1000)
@ -367,7 +364,7 @@ class SmsCommunicatorPlugin @Inject constructor(
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
} else { } else {
var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalcancelfailed) var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalcancelfailed)
replyText += "\n" + configBuilderPlugin.activePump?.shortStatus(true) replyText += "\n" + activePluginProvider.activePump?.shortStatus(true)
sendSMS(Sms(receivedSms.phoneNumber, replyText)) sendSMS(Sms(receivedSms.phoneNumber, replyText))
} }
} }
@ -414,9 +411,9 @@ class SmsCommunicatorPlugin @Inject constructor(
} }
private fun processPUMP(receivedSms: Sms) { private fun processPUMP(receivedSms: Sms) {
configBuilderPlugin.commandQueue.readStatus("SMS", object : Callback() { commandQueueProvider.commandQueue.readStatus("SMS", object : Callback() {
override fun run() { override fun run() {
val pump = configBuilderPlugin.activePump val pump = activePluginProvider.activePump
if (result.success) { if (result.success) {
if (pump != null) { if (pump != null) {
val reply = pump.shortStatus(true) val reply = pump.shortStatus(true)
@ -432,7 +429,7 @@ class SmsCommunicatorPlugin @Inject constructor(
} }
private fun processPROFILE(splitted: Array<String>, receivedSms: Sms) { // load profiles private fun processPROFILE(splitted: Array<String>, receivedSms: Sms) { // load profiles
val anInterface = configBuilderPlugin.activeProfileInterface val anInterface = activePluginProvider.activeProfileInterface
val store = anInterface.profile val store = anInterface.profile
if (store == null) { if (store == null) {
sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.notconfigured))) sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.notconfigured)))
@ -488,15 +485,15 @@ class SmsCommunicatorPlugin @Inject constructor(
receivedSms.processed = true receivedSms.processed = true
messageToConfirm = AuthRequest(this, resourceHelper, receivedSms, reply, passCode, object : SmsAction() { messageToConfirm = AuthRequest(this, resourceHelper, receivedSms, reply, passCode, object : SmsAction() {
override fun run() { override fun run() {
configBuilderPlugin.commandQueue.cancelTempBasal(true, object : Callback() { commandQueueProvider.commandQueue.cancelTempBasal(true, object : Callback() {
override fun run() { override fun run() {
if (result.success) { if (result.success) {
var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalcanceled) var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalcanceled)
replyText += "\n" + configBuilderPlugin.activePump?.shortStatus(true) replyText += "\n" + activePluginProvider.activePump?.shortStatus(true)
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
} else { } else {
var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalcancelfailed) var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalcancelfailed)
replyText += "\n" + configBuilderPlugin.activePump?.shortStatus(true) replyText += "\n" + activePluginProvider.activePump?.shortStatus(true)
sendSMS(Sms(receivedSms.phoneNumber, replyText)) sendSMS(Sms(receivedSms.phoneNumber, replyText))
} }
} }
@ -518,16 +515,16 @@ class SmsCommunicatorPlugin @Inject constructor(
receivedSms.processed = true receivedSms.processed = true
messageToConfirm = AuthRequest(this, resourceHelper, receivedSms, reply, passCode, object : SmsAction(tempBasalPct, duration) { messageToConfirm = AuthRequest(this, resourceHelper, receivedSms, reply, passCode, object : SmsAction(tempBasalPct, duration) {
override fun run() { override fun run() {
configBuilderPlugin.commandQueue.tempBasalPercent(anInteger(), secondInteger(), true, profile, object : Callback() { commandQueueProvider.commandQueue.tempBasalPercent(anInteger(), secondInteger(), true, profile, object : Callback() {
override fun run() { override fun run() {
if (result.success) { if (result.success) {
var replyText: String var replyText: String
replyText = if (result.isPercent) String.format(resourceHelper.gs(R.string.smscommunicator_tempbasalset_percent), result.percent, result.duration) else String.format(resourceHelper.gs(R.string.smscommunicator_tempbasalset), result.absolute, result.duration) replyText = if (result.isPercent) String.format(resourceHelper.gs(R.string.smscommunicator_tempbasalset_percent), result.percent, result.duration) else String.format(resourceHelper.gs(R.string.smscommunicator_tempbasalset), result.absolute, result.duration)
replyText += "\n" + configBuilderPlugin.activePump?.shortStatus(true) replyText += "\n" + activePluginProvider.activePump?.shortStatus(true)
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
} else { } else {
var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalfailed) var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalfailed)
replyText += "\n" + configBuilderPlugin.activePump?.shortStatus(true) replyText += "\n" + activePluginProvider.activePump?.shortStatus(true)
sendSMS(Sms(receivedSms.phoneNumber, replyText)) sendSMS(Sms(receivedSms.phoneNumber, replyText))
} }
} }
@ -550,16 +547,16 @@ class SmsCommunicatorPlugin @Inject constructor(
receivedSms.processed = true receivedSms.processed = true
messageToConfirm = AuthRequest(this, resourceHelper, receivedSms, reply, passCode, object : SmsAction(tempBasal, duration) { messageToConfirm = AuthRequest(this, resourceHelper, receivedSms, reply, passCode, object : SmsAction(tempBasal, duration) {
override fun run() { override fun run() {
configBuilderPlugin.commandQueue.tempBasalAbsolute(aDouble(), secondInteger(), true, profile, object : Callback() { commandQueueProvider.commandQueue.tempBasalAbsolute(aDouble(), secondInteger(), true, profile, object : Callback() {
override fun run() { override fun run() {
if (result.success) { if (result.success) {
var replyText = if (result.isPercent) String.format(resourceHelper.gs(R.string.smscommunicator_tempbasalset_percent), result.percent, result.duration) var replyText = if (result.isPercent) String.format(resourceHelper.gs(R.string.smscommunicator_tempbasalset_percent), result.percent, result.duration)
else String.format(resourceHelper.gs(R.string.smscommunicator_tempbasalset), result.absolute, result.duration) else String.format(resourceHelper.gs(R.string.smscommunicator_tempbasalset), result.absolute, result.duration)
replyText += "\n" + configBuilderPlugin.activePump?.shortStatus(true) replyText += "\n" + activePluginProvider.activePump?.shortStatus(true)
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
} else { } else {
var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalfailed) var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalfailed)
replyText += "\n" + configBuilderPlugin.activePump?.shortStatus(true) replyText += "\n" + activePluginProvider.activePump?.shortStatus(true)
sendSMS(Sms(receivedSms.phoneNumber, replyText)) sendSMS(Sms(receivedSms.phoneNumber, replyText))
} }
} }
@ -577,15 +574,15 @@ class SmsCommunicatorPlugin @Inject constructor(
receivedSms.processed = true receivedSms.processed = true
messageToConfirm = AuthRequest(this, resourceHelper, receivedSms, reply, passCode, object : SmsAction() { messageToConfirm = AuthRequest(this, resourceHelper, receivedSms, reply, passCode, object : SmsAction() {
override fun run() { override fun run() {
configBuilderPlugin.commandQueue.cancelExtended(object : Callback() { commandQueueProvider.commandQueue.cancelExtended(object : Callback() {
override fun run() { override fun run() {
if (result.success) { if (result.success) {
var replyText = resourceHelper.gs(R.string.smscommunicator_extendedcanceled) var replyText = resourceHelper.gs(R.string.smscommunicator_extendedcanceled)
replyText += "\n" + configBuilderPlugin.activePump?.shortStatus(true) replyText += "\n" + activePluginProvider.activePump?.shortStatus(true)
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
} else { } else {
var replyText = resourceHelper.gs(R.string.smscommunicator_extendedcancelfailed) var replyText = resourceHelper.gs(R.string.smscommunicator_extendedcancelfailed)
replyText += "\n" + configBuilderPlugin.activePump?.shortStatus(true) replyText += "\n" + activePluginProvider.activePump?.shortStatus(true)
sendSMS(Sms(receivedSms.phoneNumber, replyText)) sendSMS(Sms(receivedSms.phoneNumber, replyText))
} }
} }
@ -605,15 +602,15 @@ class SmsCommunicatorPlugin @Inject constructor(
receivedSms.processed = true receivedSms.processed = true
messageToConfirm = AuthRequest(this, resourceHelper, receivedSms, reply, passCode, object : SmsAction(extended, duration) { messageToConfirm = AuthRequest(this, resourceHelper, receivedSms, reply, passCode, object : SmsAction(extended, duration) {
override fun run() { override fun run() {
configBuilderPlugin.commandQueue.extendedBolus(aDouble(), secondInteger(), object : Callback() { commandQueueProvider.commandQueue.extendedBolus(aDouble(), secondInteger(), object : Callback() {
override fun run() { override fun run() {
if (result.success) { if (result.success) {
var replyText = String.format(resourceHelper.gs(R.string.smscommunicator_extendedset), aDouble, duration) var replyText = String.format(resourceHelper.gs(R.string.smscommunicator_extendedset), aDouble, duration)
replyText += "\n" + configBuilderPlugin.activePump?.shortStatus(true) replyText += "\n" + activePluginProvider.activePump?.shortStatus(true)
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
} else { } else {
var replyText = resourceHelper.gs(R.string.smscommunicator_extendedfailed) var replyText = resourceHelper.gs(R.string.smscommunicator_extendedfailed)
replyText += "\n" + configBuilderPlugin.activePump?.shortStatus(true) replyText += "\n" + activePluginProvider.activePump?.shortStatus(true)
sendSMS(Sms(receivedSms.phoneNumber, replyText)) sendSMS(Sms(receivedSms.phoneNumber, replyText))
} }
} }
@ -642,18 +639,18 @@ class SmsCommunicatorPlugin @Inject constructor(
val detailedBolusInfo = DetailedBolusInfo() val detailedBolusInfo = DetailedBolusInfo()
detailedBolusInfo.insulin = aDouble() detailedBolusInfo.insulin = aDouble()
detailedBolusInfo.source = Source.USER detailedBolusInfo.source = Source.USER
configBuilderPlugin.commandQueue.bolus(detailedBolusInfo, object : Callback() { commandQueueProvider.commandQueue.bolus(detailedBolusInfo, object : Callback() {
override fun run() { override fun run() {
val resultSuccess = result.success val resultSuccess = result.success
val resultBolusDelivered = result.bolusDelivered val resultBolusDelivered = result.bolusDelivered
configBuilderPlugin.commandQueue.readStatus("SMS", object : Callback() { commandQueueProvider.commandQueue.readStatus("SMS", object : Callback() {
override fun run() { override fun run() {
if (resultSuccess) { if (resultSuccess) {
var replyText = if (isMeal) var replyText = if (isMeal)
String.format(resourceHelper.gs(R.string.smscommunicator_mealbolusdelivered), resultBolusDelivered) String.format(resourceHelper.gs(R.string.smscommunicator_mealbolusdelivered), resultBolusDelivered)
else else
String.format(resourceHelper.gs(R.string.smscommunicator_bolusdelivered), resultBolusDelivered) String.format(resourceHelper.gs(R.string.smscommunicator_bolusdelivered), resultBolusDelivered)
replyText += "\n" + configBuilderPlugin.activePump?.shortStatus(true) replyText += "\n" + activePluginProvider.activePump?.shortStatus(true)
lastRemoteBolusTime = DateUtil.now() lastRemoteBolusTime = DateUtil.now()
if (isMeal) { if (isMeal) {
profileFunction.getProfile()?.let { currentProfile -> profileFunction.getProfile()?.let { currentProfile ->
@ -683,7 +680,7 @@ class SmsCommunicatorPlugin @Inject constructor(
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
} else { } else {
var replyText = resourceHelper.gs(R.string.smscommunicator_bolusfailed) var replyText = resourceHelper.gs(R.string.smscommunicator_bolusfailed)
replyText += "\n" + configBuilderPlugin.activePump?.shortStatus(true) replyText += "\n" + activePluginProvider.activePump?.shortStatus(true)
sendSMS(Sms(receivedSms.phoneNumber, replyText)) sendSMS(Sms(receivedSms.phoneNumber, replyText))
} }
} }
@ -718,15 +715,15 @@ class SmsCommunicatorPlugin @Inject constructor(
val detailedBolusInfo = DetailedBolusInfo() val detailedBolusInfo = DetailedBolusInfo()
detailedBolusInfo.carbs = anInteger().toDouble() detailedBolusInfo.carbs = anInteger().toDouble()
detailedBolusInfo.date = secondLong() detailedBolusInfo.date = secondLong()
configBuilderPlugin.commandQueue.bolus(detailedBolusInfo, object : Callback() { commandQueueProvider.commandQueue.bolus(detailedBolusInfo, object : Callback() {
override fun run() { override fun run() {
if (result.success) { if (result.success) {
var replyText = String.format(resourceHelper.gs(R.string.smscommunicator_carbsset), anInteger) var replyText = String.format(resourceHelper.gs(R.string.smscommunicator_carbsset), anInteger)
replyText += "\n" + configBuilderPlugin.activePump?.shortStatus(true) replyText += "\n" + activePluginProvider.activePump?.shortStatus(true)
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
} else { } else {
var replyText = resourceHelper.gs(R.string.smscommunicator_carbsfailed) var replyText = resourceHelper.gs(R.string.smscommunicator_carbsfailed)
replyText += "\n" + configBuilderPlugin.activePump?.shortStatus(true) replyText += "\n" + activePluginProvider.activePump?.shortStatus(true)
sendSMS(Sms(receivedSms.phoneNumber, replyText)) sendSMS(Sms(receivedSms.phoneNumber, replyText))
} }
} }

View file

@ -6,13 +6,13 @@ import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.data.Profile
import info.nightscout.androidaps.events.* import info.nightscout.androidaps.events.*
import info.nightscout.androidaps.interfaces.ActivePluginProvider
import info.nightscout.androidaps.interfaces.PluginBase import info.nightscout.androidaps.interfaces.PluginBase
import info.nightscout.androidaps.interfaces.PluginDescription import info.nightscout.androidaps.interfaces.PluginDescription
import info.nightscout.androidaps.interfaces.PluginType import info.nightscout.androidaps.interfaces.PluginType
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished
@ -34,7 +34,7 @@ class StatusLinePlugin @Inject constructor(
private val resourceHelper: ResourceHelper, private val resourceHelper: ResourceHelper,
private val mainApp: MainApp, private val mainApp: MainApp,
private val fabricPrivacy: FabricPrivacy, private val fabricPrivacy: FabricPrivacy,
private val configBuilderPlugin: ConfigBuilderPlugin, private val activePluginProvider: ActivePluginProvider,
private val treatmentsPlugin: TreatmentsPlugin, private val treatmentsPlugin: TreatmentsPlugin,
private val loopPlugin: LoopPlugin, private val loopPlugin: LoopPlugin,
private val iobCobCalculatorPlugin: IobCobCalculatorPlugin, private val iobCobCalculatorPlugin: IobCobCalculatorPlugin,
@ -112,7 +112,7 @@ class StatusLinePlugin @Inject constructor(
private fun buildStatusString(profile: Profile): String { private fun buildStatusString(profile: Profile): String {
var status = "" var status = ""
if (configBuilderPlugin.activePump == null) return "" if (activePluginProvider.activePump == null) return ""
if (!loopPlugin.isEnabled(PluginType.LOOP)) { if (!loopPlugin.isEnabled(PluginType.LOOP)) {
status += resourceHelper.gs(R.string.disabledloop) + "\n" status += resourceHelper.gs(R.string.disabledloop) + "\n"
lastLoopStatus = false lastLoopStatus = false

View file

@ -13,6 +13,7 @@ import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.data.Profile
import info.nightscout.androidaps.dialogs.ProfileSwitchDialog import info.nightscout.androidaps.dialogs.ProfileSwitchDialog
import info.nightscout.androidaps.interfaces.ActivePluginProvider
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
import info.nightscout.androidaps.plugins.insulin.InsulinOrefBasePlugin.Companion.MIN_DIA import info.nightscout.androidaps.plugins.insulin.InsulinOrefBasePlugin.Companion.MIN_DIA
@ -29,7 +30,7 @@ import javax.inject.Inject
class LocalProfileFragment : DaggerFragment() { class LocalProfileFragment : DaggerFragment() {
@Inject lateinit var rxBus: RxBusWrapper @Inject lateinit var rxBus: RxBusWrapper
@Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var resourceHelper: ResourceHelper
@Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin @Inject lateinit var activePluginProvider: ActivePluginProvider
@Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var fabricPrivacy: FabricPrivacy
@Inject lateinit var localProfilePlugin: LocalProfilePlugin @Inject lateinit var localProfilePlugin: LocalProfilePlugin
@ -93,7 +94,7 @@ class LocalProfileFragment : DaggerFragment() {
} }
fun build() { fun build() {
val pumpDescription = configBuilderPlugin.activePump?.pumpDescription ?: return val pumpDescription = activePluginProvider.activePump?.pumpDescription ?: return
val units = if (localProfilePlugin.currentProfile().mgdl) Constants.MGDL else Constants.MMOL val units = if (localProfilePlugin.currentProfile().mgdl) Constants.MGDL else Constants.MMOL
localprofile_name.removeTextChangedListener(textWatch) localprofile_name.removeTextChangedListener(textWatch)

View file

@ -11,11 +11,12 @@ import dagger.android.DaggerBroadcastReceiver
import info.nightscout.androidaps.Config import info.nightscout.androidaps.Config
import info.nightscout.androidaps.db.DatabaseHelper import info.nightscout.androidaps.db.DatabaseHelper
import info.nightscout.androidaps.events.EventProfileNeedsUpdate import info.nightscout.androidaps.events.EventProfileNeedsUpdate
import info.nightscout.androidaps.interfaces.ActivePluginProvider
import info.nightscout.androidaps.interfaces.CommandQueueProvider
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
import info.nightscout.androidaps.queue.commands.Command import info.nightscout.androidaps.queue.commands.Command
@ -29,7 +30,8 @@ import kotlin.math.abs
class KeepAliveReceiver : DaggerBroadcastReceiver() { class KeepAliveReceiver : DaggerBroadcastReceiver() {
@Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var rxBus: RxBusWrapper @Inject lateinit var rxBus: RxBusWrapper
@Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin @Inject lateinit var activePluginProvider: ActivePluginProvider
@Inject lateinit var commandQueueProvider: CommandQueueProvider
@Inject lateinit var profileFunction: ProfileFunction @Inject lateinit var profileFunction: ProfileFunction
@Inject lateinit var loopPlugin: LoopPlugin @Inject lateinit var loopPlugin: LoopPlugin
@ -88,7 +90,7 @@ class KeepAliveReceiver : DaggerBroadcastReceiver() {
// if there is no BG available, we have to upload anyway to have correct // if there is no BG available, we have to upload anyway to have correct
// IOB displayed in NS // IOB displayed in NS
private fun checkAPS() { private fun checkAPS() {
val usedAPS = configBuilderPlugin.activeAPS val usedAPS = activePluginProvider.activeAPS
var shouldUploadStatus = false var shouldUploadStatus = false
if (Config.NSCLIENT) return if (Config.NSCLIENT) return
if (Config.PUMPCONTROL) shouldUploadStatus = true if (Config.PUMPCONTROL) shouldUploadStatus = true
@ -102,7 +104,7 @@ class KeepAliveReceiver : DaggerBroadcastReceiver() {
} }
private fun checkPump() { private fun checkPump() {
val pump = configBuilderPlugin.activePump ?: return val pump = activePluginProvider.activePump ?: return
val profile = profileFunction.getProfile() ?: return val profile = profileFunction.getProfile() ?: return
val lastConnection = pump.lastDataTime() val lastConnection = pump.lastDataTime()
val isStatusOutdated = lastConnection + STATUS_UPDATE_FREQUENCY < System.currentTimeMillis() val isStatusOutdated = lastConnection + STATUS_UPDATE_FREQUENCY < System.currentTimeMillis()
@ -113,14 +115,14 @@ class KeepAliveReceiver : DaggerBroadcastReceiver() {
if (lastReadStatus != 0L && lastReadStatus > System.currentTimeMillis() - T.mins(5).msecs()) { if (lastReadStatus != 0L && lastReadStatus > System.currentTimeMillis() - T.mins(5).msecs()) {
LocalAlertUtils.checkPumpUnreachableAlarm(lastConnection, isStatusOutdated, loopPlugin.isDisconnected) LocalAlertUtils.checkPumpUnreachableAlarm(lastConnection, isStatusOutdated, loopPlugin.isDisconnected)
} }
if (!pump.isThisProfileSet(profile) && !configBuilderPlugin.commandQueue.isRunning(Command.CommandType.BASALPROFILE)) { if (!pump.isThisProfileSet(profile) && !commandQueueProvider.commandQueue.isRunning(Command.CommandType.BASALPROFILE)) {
rxBus.send(EventProfileNeedsUpdate()) rxBus.send(EventProfileNeedsUpdate())
} else if (isStatusOutdated && !pump.isBusy) { } else if (isStatusOutdated && !pump.isBusy) {
lastReadStatus = System.currentTimeMillis() lastReadStatus = System.currentTimeMillis()
configBuilderPlugin.commandQueue.readStatus("KeepAlive. Status outdated.", null) commandQueueProvider.commandQueue.readStatus("KeepAlive. Status outdated.", null)
} else if (isBasalOutdated && !pump.isBusy) { } else if (isBasalOutdated && !pump.isBusy) {
lastReadStatus = System.currentTimeMillis() lastReadStatus = System.currentTimeMillis()
configBuilderPlugin.commandQueue.readStatus("KeepAlive. Basal outdated.", null) commandQueueProvider.commandQueue.readStatus("KeepAlive. Basal outdated.", null)
} }
if (lastRun != 0L && System.currentTimeMillis() - lastRun > T.mins(10).msecs()) { if (lastRun != 0L && System.currentTimeMillis() - lastRun > T.mins(10).msecs()) {
aapsLogger.error(LTag.CORE, "KeepAlive fail") aapsLogger.error(LTag.CORE, "KeepAlive fail")

View file

@ -13,15 +13,11 @@ import info.nightscout.androidaps.db.CareportalEvent
import info.nightscout.androidaps.db.Source import info.nightscout.androidaps.db.Source
import info.nightscout.androidaps.db.TempTarget import info.nightscout.androidaps.db.TempTarget
import info.nightscout.androidaps.events.EventRefreshOverview import info.nightscout.androidaps.events.EventRefreshOverview
import info.nightscout.androidaps.interfaces.Constraint import info.nightscout.androidaps.interfaces.*
import info.nightscout.androidaps.interfaces.PluginType
import info.nightscout.androidaps.interfaces.PumpDescription
import info.nightscout.androidaps.interfaces.PumpInterface
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
@ -50,7 +46,8 @@ class BolusWizard @Inject constructor(
@Inject lateinit var profileFunction: ProfileFunction @Inject lateinit var profileFunction: ProfileFunction
@Inject lateinit var constraintChecker: ConstraintChecker @Inject lateinit var constraintChecker: ConstraintChecker
@Inject lateinit var treatmentsPlugin: TreatmentsPlugin @Inject lateinit var treatmentsPlugin: TreatmentsPlugin
@Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin @Inject lateinit var activePluginProvider: ActivePluginProvider
@Inject lateinit var commandQueueProvider: CommandQueueProvider
@Inject lateinit var loopPlugin: LoopPlugin @Inject lateinit var loopPlugin: LoopPlugin
@Inject lateinit var iobCobCalculatorPlugin: IobCobCalculatorPlugin @Inject lateinit var iobCobCalculatorPlugin: IobCobCalculatorPlugin
@ -222,7 +219,7 @@ class BolusWizard @Inject constructor(
calculatedTotalInsulin = 0.0 calculatedTotalInsulin = 0.0
} }
val bolusStep = configBuilderPlugin.activePump?.pumpDescription?.bolusStep val bolusStep = activePluginProvider.activePump?.pumpDescription?.bolusStep
?: 0.1 ?: 0.1
calculatedTotalInsulin = Round.roundTo(calculatedTotalInsulin, bolusStep) calculatedTotalInsulin = Round.roundTo(calculatedTotalInsulin, bolusStep)
@ -304,7 +301,7 @@ class BolusWizard @Inject constructor(
fun confirmAndExecute(context: Context) { fun confirmAndExecute(context: Context) {
val profile = profileFunction.getProfile() ?: return val profile = profileFunction.getProfile() ?: return
val pump = configBuilderPlugin.activePump ?: return val pump = activePluginProvider.activePump ?: return
if (calculatedTotalInsulin > 0.0 || carbs > 0.0) { if (calculatedTotalInsulin > 0.0 || carbs > 0.0) {
if (accepted) { if (accepted) {
@ -324,7 +321,7 @@ class BolusWizard @Inject constructor(
} }
if (pump.pumpDescription?.tempBasalStyle == PumpDescription.ABSOLUTE) { if (pump.pumpDescription?.tempBasalStyle == PumpDescription.ABSOLUTE) {
configBuilderPlugin.commandQueue.tempBasalAbsolute(0.0, 120, true, profile, object : Callback() { commandQueueProvider.commandQueue.tempBasalAbsolute(0.0, 120, true, profile, object : Callback() {
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {
val i = Intent(mainApp, ErrorHelperActivity::class.java) val i = Intent(mainApp, ErrorHelperActivity::class.java)
@ -338,7 +335,7 @@ class BolusWizard @Inject constructor(
}) })
} else { } else {
configBuilderPlugin.commandQueue.tempBasalPercent(0, 120, true, profile, object : Callback() { commandQueueProvider.commandQueue.tempBasalPercent(0, 120, true, profile, object : Callback() {
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {
val i = Intent(mainApp, ErrorHelperActivity::class.java) val i = Intent(mainApp, ErrorHelperActivity::class.java)
@ -364,7 +361,7 @@ class BolusWizard @Inject constructor(
detailedBolusInfo.source = Source.USER detailedBolusInfo.source = Source.USER
detailedBolusInfo.notes = notes detailedBolusInfo.notes = notes
if (detailedBolusInfo.insulin > 0 || pump.pumpDescription?.storesCarbInfo == true) { if (detailedBolusInfo.insulin > 0 || pump.pumpDescription?.storesCarbInfo == true) {
configBuilderPlugin.commandQueue.bolus(detailedBolusInfo, object : Callback() { commandQueueProvider.commandQueue.bolus(detailedBolusInfo, object : Callback() {
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {
val i = Intent(mainApp, ErrorHelperActivity::class.java) val i = Intent(mainApp, ErrorHelperActivity::class.java)