- fixed refresh of config data (I hope)

- if podmanagement changes some pod status
This commit is contained in:
Andy Rozman 2019-12-08 20:55:24 +00:00
parent 9b5535edf0
commit bdb3bc0b8e
3 changed files with 48 additions and 2 deletions

View file

@ -28,6 +28,7 @@ import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.db.Source; import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.db.TemporaryBasal; import info.nightscout.androidaps.db.TemporaryBasal;
import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.events.EventRefreshOverview; import info.nightscout.androidaps.events.EventRefreshOverview;
import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PluginType;
@ -36,6 +37,7 @@ import info.nightscout.androidaps.plugins.bus.RxBus;
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction; import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction;
import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType; import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType;
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress;
import info.nightscout.androidaps.plugins.pump.common.PumpPluginAbstract; import info.nightscout.androidaps.plugins.pump.common.PumpPluginAbstract;
import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair; import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair;
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDriverState; import info.nightscout.androidaps.plugins.pump.common.defs.PumpDriverState;
@ -62,8 +64,11 @@ import info.nightscout.androidaps.plugins.pump.omnipod.util.LogReceiver;
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst; import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst;
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil; import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin; import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
import info.nightscout.androidaps.utils.FabricPrivacy;
import info.nightscout.androidaps.utils.OKDialog; import info.nightscout.androidaps.utils.OKDialog;
import info.nightscout.androidaps.utils.SP; import info.nightscout.androidaps.utils.SP;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.schedulers.Schedulers;
/** /**
* Created by andy on 23.04.18. * Created by andy on 23.04.18.
@ -78,6 +83,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
private RileyLinkOmnipodService omnipodService; private RileyLinkOmnipodService omnipodService;
protected OmnipodPumpStatus pumpStatusLocal = null; protected OmnipodPumpStatus pumpStatusLocal = null;
protected OmnipodUIComm omnipodUIComm; protected OmnipodUIComm omnipodUIComm;
private CompositeDisposable disposable = new CompositeDisposable();
// variables for handling statuses and history // variables for handling statuses and history
protected boolean firstRun = true; protected boolean firstRun = true;
@ -166,6 +172,34 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
} }
@Override
protected void onStart() {
super.onStart();
disposable.add(RxBus.INSTANCE
.toObservable(EventPreferenceChange.class)
.observeOn(Schedulers.io())
.subscribe(event -> {
if ((event.isChanged(R.string.key_omnipod_beep_basal_enabled)) ||
(event.isChanged(R.string.key_omnipod_beep_bolus_enabled)) ||
(event.isChanged(R.string.key_omnipod_beep_smb_enabled)))
refreshConfiguration();
}, FabricPrivacy::logException)
);
refreshConfiguration();
}
private void refreshConfiguration() {
if (pumpStatusLocal!=null) {
pumpStatusLocal.refreshConfiguration();
}
}
@Override
protected void onStop() {
disposable.clear();
super.onStop();
}
private String getLogPrefix() { private String getLogPrefix() {
return "OmnipodPlugin::"; return "OmnipodPlugin::";
} }
@ -417,7 +451,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
} }
triggerUIChange(); triggerUIChange();
RxBus.INSTANCE.send(new EventOmnipodPumpValuesChanged()); RxBus.INSTANCE.send(new EventRefreshOverview("Omnipod Pump"));
getPodPumpStatus(); getPodPumpStatus();

View file

@ -9,6 +9,7 @@ import com.atech.android.library.wizardpager.defs.WizardStepsWayType
import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.activities.NoSplashActivity import info.nightscout.androidaps.activities.NoSplashActivity
import info.nightscout.androidaps.events.EventRefreshOverview
import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsOmnipodManager import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsOmnipodManager
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.initpod.InitPodCancelAction import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.initpod.InitPodCancelAction
@ -25,6 +26,8 @@ import kotlinx.android.synthetic.main.omnipod_pod_mgmt.*
*/ */
class PodManagementActivity : NoSplashActivity() { class PodManagementActivity : NoSplashActivity() {
private var podSessionActiveOnStart:Boolean? = null
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.omnipod_pod_mgmt) setContentView(R.layout.omnipod_pod_mgmt)
@ -53,7 +56,10 @@ class PodManagementActivity : NoSplashActivity() {
override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
RxBus.send(EventOmnipodPumpValuesChanged()) if (podSessionActiveOnStart!=(OmnipodUtil.getPodSessionState()!=null)) {
RxBus.send(EventOmnipodPumpValuesChanged())
RxBus.send(EventRefreshOverview())
}
} }
@ -121,6 +127,10 @@ class PodManagementActivity : NoSplashActivity() {
val isPodSessionActive = (OmnipodUtil.getPodSessionState()!=null) val isPodSessionActive = (OmnipodUtil.getPodSessionState()!=null)
if (podSessionActiveOnStart==null) {
podSessionActiveOnStart = isPodSessionActive
}
initpod_init_pod.isEnabled = !isPodSessionActive initpod_init_pod.isEnabled = !isPodSessionActive
initpod_remove_pod.isEnabled = isPodSessionActive initpod_remove_pod.isEnabled = isPodSessionActive
initpod_reset_pod.isEnabled = isPodSessionActive initpod_reset_pod.isEnabled = isPodSessionActive

View file

@ -105,6 +105,8 @@ public class OmnipodPumpStatus extends PumpStatus {
this.beepBolusEnabled = SP.getBoolean(OmnipodConst.Prefs.BeepBolusEnabled, true); this.beepBolusEnabled = SP.getBoolean(OmnipodConst.Prefs.BeepBolusEnabled, true);
this.beepSMBEnabled = SP.getBoolean(OmnipodConst.Prefs.BeepSMBEnabled, true); this.beepSMBEnabled = SP.getBoolean(OmnipodConst.Prefs.BeepSMBEnabled, true);
LOG.debug("Beeps [basal={}, bolus={}, SMB={}]", this.beepBasalEnabled, this.beepBolusEnabled, this.beepSMBEnabled);
reconfigureService(); reconfigureService();
return true; return true;