Events to RxBus
This commit is contained in:
parent
ada6e38f5f
commit
64f16c5a7b
38 changed files with 322 additions and 303 deletions
|
@ -1577,7 +1577,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
|||
public void run() {
|
||||
if (L.isEnabled(L.DATABASE))
|
||||
log.debug("Firing scheduleCareportalEventChange");
|
||||
MainApp.bus().post(new EventCareportalEventChange());
|
||||
RxBus.INSTANCE.send(new EventCareportalEventChange());
|
||||
scheduledCareportalEventPost = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
package info.nightscout.androidaps.events;
|
||||
|
||||
/** Base class for events to update the UI, mostly a specific tab. */
|
||||
public class EventAcceptOpenLoopChange extends Event {
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
package info.nightscout.androidaps.events
|
||||
|
||||
class EventAcceptOpenLoopChange : Event()
|
|
@ -1,8 +0,0 @@
|
|||
package info.nightscout.androidaps.events;
|
||||
|
||||
/**
|
||||
* Created by mike on 25.05.2017.
|
||||
*/
|
||||
|
||||
public class EventCareportalEventChange extends Event {
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
package info.nightscout.androidaps.events
|
||||
|
||||
class EventCareportalEventChange : Event()
|
|
@ -1,8 +0,0 @@
|
|||
package info.nightscout.androidaps.events;
|
||||
|
||||
/**
|
||||
* Created by mike on 17.02.2017.
|
||||
*/
|
||||
|
||||
public class EventConfigBuilderChange extends Event {
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
package info.nightscout.androidaps.events
|
||||
|
||||
class EventConfigBuilderChange : Event()
|
|
@ -1,8 +0,0 @@
|
|||
package info.nightscout.androidaps.events;
|
||||
|
||||
/**
|
||||
* Created by mike on 13.12.2016.
|
||||
*/
|
||||
|
||||
public class EventInitializationChanged extends Event {
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
package info.nightscout.androidaps.events
|
||||
|
||||
class EventInitializationChanged : Event()
|
|
@ -1,11 +0,0 @@
|
|||
package info.nightscout.androidaps.events;
|
||||
|
||||
import android.location.Location;
|
||||
|
||||
public class EventLocationChange extends Event {
|
||||
public Location location;
|
||||
|
||||
public EventLocationChange(Location location) {
|
||||
this.location = location;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package info.nightscout.androidaps.events
|
||||
|
||||
import android.location.Location
|
||||
|
||||
class EventLocationChange(var location: Location) : Event()
|
|
@ -1,17 +0,0 @@
|
|||
package info.nightscout.androidaps.events;
|
||||
|
||||
|
||||
import info.nightscout.androidaps.utils.StringUtils;
|
||||
|
||||
public class EventNetworkChange extends Event {
|
||||
|
||||
public boolean mobileConnected = false;
|
||||
public boolean wifiConnected = false;
|
||||
|
||||
public String ssid = "";
|
||||
public boolean roaming = false;
|
||||
|
||||
public String getSsid() {
|
||||
return StringUtils.removeSurroundingQuotes(ssid);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package info.nightscout.androidaps.events
|
||||
|
||||
import info.nightscout.androidaps.utils.StringUtils
|
||||
|
||||
class EventNetworkChange : Event() {
|
||||
|
||||
var mobileConnected = false
|
||||
var wifiConnected = false
|
||||
|
||||
var ssid = ""
|
||||
var roaming = false
|
||||
|
||||
fun connectedSsid(): String {
|
||||
return StringUtils.removeSurroundingQuotes(ssid)
|
||||
}
|
||||
}
|
|
@ -477,7 +477,7 @@ public class LoopPlugin extends PluginBase {
|
|||
NSUpload.uploadDeviceStatus();
|
||||
SP.incInt(R.string.key_ObjectivesmanualEnacts);
|
||||
}
|
||||
MainApp.bus().post(new EventAcceptOpenLoopChange());
|
||||
RxBus.INSTANCE.send(new EventAcceptOpenLoopChange());
|
||||
}
|
||||
});
|
||||
FabricPrivacy.getInstance().logCustom("AcceptTemp");
|
||||
|
|
|
@ -59,13 +59,13 @@ public class TriggerWifiSsid extends Trigger {
|
|||
if (lastRun > DateUtil.now() - T.mins(5).msecs())
|
||||
return false;
|
||||
|
||||
if (!eventNetworkChange.wifiConnected && comparator.getValue() == Comparator.Compare.IS_NOT_AVAILABLE) {
|
||||
if (!eventNetworkChange.getWifiConnected() && comparator.getValue() == Comparator.Compare.IS_NOT_AVAILABLE) {
|
||||
if (L.isEnabled(L.AUTOMATION))
|
||||
log.debug("Ready for execution: " + friendlyDescription());
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean doRun = eventNetworkChange.wifiConnected && comparator.getValue().check(eventNetworkChange.getSsid(), getValue());
|
||||
boolean doRun = eventNetworkChange.getWifiConnected() && comparator.getValue().check(eventNetworkChange.connectedSsid(), getValue());
|
||||
if (doRun) {
|
||||
if (L.isEnabled(L.AUTOMATION))
|
||||
log.debug("Ready for execution: " + friendlyDescription());
|
||||
|
|
|
@ -4,14 +4,14 @@ package info.nightscout.androidaps.plugins.general.careportal;
|
|||
import android.app.Activity;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.squareup.otto.Subscribe;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -22,19 +22,18 @@ import info.nightscout.androidaps.R;
|
|||
import info.nightscout.androidaps.data.ProfileStore;
|
||||
import info.nightscout.androidaps.db.CareportalEvent;
|
||||
import info.nightscout.androidaps.events.EventCareportalEventChange;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.general.careportal.Dialogs.NewNSTreatmentDialog;
|
||||
import info.nightscout.androidaps.plugins.common.SubscriberFragment;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.general.careportal.Dialogs.NewNSTreatmentDialog;
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus;
|
||||
import info.nightscout.androidaps.plugins.general.overview.OverviewFragment;
|
||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
import info.nightscout.androidaps.utils.SetWarnColor;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
|
||||
public class CareportalFragment extends SubscriberFragment implements View.OnClickListener {
|
||||
public class CareportalFragment extends Fragment implements View.OnClickListener {
|
||||
private static Logger log = LoggerFactory.getLogger(CareportalFragment.class);
|
||||
private CompositeDisposable disposable = new CompositeDisposable();
|
||||
|
||||
TextView iage;
|
||||
TextView cage;
|
||||
|
@ -71,7 +70,6 @@ public class CareportalFragment extends SubscriberFragment implements View.OnCli
|
|||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
try {
|
||||
View view = inflater.inflate(R.layout.careportal_fragment, container, false);
|
||||
|
||||
view.findViewById(R.id.careportal_bgcheck).setOnClickListener(this);
|
||||
|
@ -117,13 +115,24 @@ public class CareportalFragment extends SubscriberFragment implements View.OnCli
|
|||
if (Config.NSCLIENT)
|
||||
statsLayout.setVisibility(View.GONE); // visible on overview
|
||||
|
||||
updateGUI();
|
||||
return view;
|
||||
} catch (Exception e) {
|
||||
FabricPrivacy.logException(e);
|
||||
}
|
||||
|
||||
return null;
|
||||
@Override
|
||||
public synchronized void onResume() {
|
||||
super.onResume();
|
||||
disposable.add(RxBus.INSTANCE
|
||||
.toObservable(EventCareportalEventChange.class)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(event -> updateGUI(), FabricPrivacy::logException)
|
||||
);
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void onPause() {
|
||||
super.onPause();
|
||||
disposable.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -203,12 +212,6 @@ public class CareportalFragment extends SubscriberFragment implements View.OnCli
|
|||
newDialog.show(manager, "NewNSTreatmentDialog");
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventCareportalEventChange c) {
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateGUI() {
|
||||
Activity activity = getActivity();
|
||||
updateAge(activity, sage, iage, cage, pbage);
|
||||
|
|
|
@ -116,6 +116,11 @@ public class NSClientPlugin extends PluginBase {
|
|||
MainApp.bus().post(new EventNSClientUpdateGUI());
|
||||
}, FabricPrivacy::logException)
|
||||
);
|
||||
disposable.add(RxBus.INSTANCE
|
||||
.toObservable(EventNetworkChange.class)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(event -> nsClientReceiverDelegate.onStatusEvent(event), FabricPrivacy::logException)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -139,12 +144,6 @@ public class NSClientPlugin extends PluginBase {
|
|||
nsClientReceiverDelegate.onStatusEvent(ev);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventNetworkChange ev) {
|
||||
nsClientReceiverDelegate.onStatusEvent(ev);
|
||||
}
|
||||
|
||||
|
||||
private ServiceConnection mConnection = new ServiceConnection() {
|
||||
|
||||
public void onServiceDisconnected(ComponentName name) {
|
||||
|
|
|
@ -46,7 +46,7 @@ class NsClientReceiverDelegate {
|
|||
|
||||
EventNetworkChange event = networkChangeReceiver.grabNetworkStatus(context);
|
||||
if (event != null)
|
||||
bus.post(event);
|
||||
RxBus.INSTANCE.send(event);
|
||||
|
||||
context.registerReceiver(chargingStateReceiver,
|
||||
new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
|
||||
|
@ -69,7 +69,7 @@ class NsClientReceiverDelegate {
|
|||
) {
|
||||
EventNetworkChange event = networkChangeReceiver.grabNetworkStatus(MainApp.instance().getApplicationContext());
|
||||
if (event != null)
|
||||
bus.post(event);
|
||||
RxBus.INSTANCE.send(event);
|
||||
} else if (ev.isChanged(R.string.key_ns_chargingonly)) {
|
||||
EventChargingState event = chargingStateReceiver.grabChargingState(MainApp.instance().getApplicationContext());
|
||||
if (event != null)
|
||||
|
@ -123,13 +123,13 @@ class NsClientReceiverDelegate {
|
|||
|
||||
boolean newAllowedState = true;
|
||||
|
||||
if (ev.wifiConnected) {
|
||||
if (ev.getWifiConnected()) {
|
||||
if (!allowedSSIDs.trim().isEmpty() &&
|
||||
(!allowedSSIDs.contains(ev.getSsid()) && !allowedSSIDs.contains(ev.ssid))) {
|
||||
(!allowedSSIDs.contains(ev.connectedSsid()) && !allowedSSIDs.contains(ev.getSsid()))) {
|
||||
newAllowedState = false;
|
||||
}
|
||||
} else {
|
||||
if ((!allowRoaming && ev.roaming) || wifiOnly) {
|
||||
if ((!allowRoaming && ev.getRoaming()) || wifiOnly) {
|
||||
newAllowedState = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,12 +69,15 @@ import info.nightscout.androidaps.utils.FabricPrivacy;
|
|||
import info.nightscout.androidaps.utils.JsonHelper;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
import info.nightscout.androidaps.utils.T;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import io.socket.client.IO;
|
||||
import io.socket.client.Socket;
|
||||
import io.socket.emitter.Emitter;
|
||||
|
||||
public class NSClientService extends Service {
|
||||
private static Logger log = LoggerFactory.getLogger(L.NSCLIENT);
|
||||
private CompositeDisposable disposable = new CompositeDisposable();
|
||||
|
||||
static public PowerManager.WakeLock mWakeLock;
|
||||
private IBinder mBinder = new NSClientService.LocalBinder();
|
||||
|
@ -114,6 +117,17 @@ public class NSClientService extends Service {
|
|||
|
||||
public NSClientService() {
|
||||
registerBus();
|
||||
disposable.add(RxBus.INSTANCE
|
||||
.toObservable(EventConfigBuilderChange.class)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(event -> {
|
||||
if (nsEnabled != NSClientPlugin.getPlugin().isEnabled(PluginType.GENERAL)) {
|
||||
latestDateInReceivedData = 0;
|
||||
destroy();
|
||||
initialize();
|
||||
}
|
||||
}, FabricPrivacy::logException)
|
||||
);
|
||||
if (handler == null) {
|
||||
HandlerThread handlerThread = new HandlerThread(NSClientService.class.getSimpleName() + "Handler");
|
||||
handlerThread.start();
|
||||
|
@ -185,15 +199,6 @@ public class NSClientService extends Service {
|
|||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(EventConfigBuilderChange ev) {
|
||||
if (nsEnabled != MainApp.getSpecificPlugin(NSClientPlugin.class).isEnabled(PluginType.GENERAL)) {
|
||||
latestDateInReceivedData = 0;
|
||||
destroy();
|
||||
initialize();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventNSClientRestart ev) {
|
||||
latestDateInReceivedData = 0;
|
||||
|
|
|
@ -900,6 +900,24 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
.subscribe(event -> scheduleUpdateGUI("EventTempTargetChange"),
|
||||
FabricPrivacy::logException
|
||||
));
|
||||
disposable.add(RxBus.INSTANCE
|
||||
.toObservable(EventAcceptOpenLoopChange.class)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(event -> scheduleUpdateGUI("EventAcceptOpenLoopChange"),
|
||||
FabricPrivacy::logException
|
||||
));
|
||||
disposable.add(RxBus.INSTANCE
|
||||
.toObservable(EventCareportalEventChange.class)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(event -> scheduleUpdateGUI("EventCareportalEventChange"),
|
||||
FabricPrivacy::logException
|
||||
));
|
||||
disposable.add(RxBus.INSTANCE
|
||||
.toObservable(EventInitializationChanged.class)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(event -> scheduleUpdateGUI("EventInitializationChanged"),
|
||||
FabricPrivacy::logException
|
||||
));
|
||||
disposable.add(RxBus.INSTANCE
|
||||
.toObservable(EventPumpStatusChanged.class)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
@ -917,11 +935,6 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
updateGUI("onResume");
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventInitializationChanged ev) {
|
||||
scheduleUpdateGUI("EventInitializationChanged");
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventPreferenceChange ev) {
|
||||
scheduleUpdateGUI("EventPreferenceChange");
|
||||
|
@ -932,21 +945,11 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
scheduleUpdateGUI("EventAutosensCalculationFinished");
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventCareportalEventChange ev) {
|
||||
scheduleUpdateGUI("EventCareportalEventChange");
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventNewOpenLoopNotification ev) {
|
||||
scheduleUpdateGUI("EventNewOpenLoopNotification");
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventAcceptOpenLoopChange ev) {
|
||||
scheduleUpdateGUI("EventAcceptOpenLoopChange");
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventProfileNeedsUpdate ev) {
|
||||
scheduleUpdateGUI("EventProfileNeedsUpdate");
|
||||
|
|
|
@ -120,6 +120,12 @@ public class PersistentNotificationPlugin extends PluginBase {
|
|||
.subscribe(event -> triggerNotificationUpdate(false),
|
||||
FabricPrivacy::logException
|
||||
));
|
||||
disposable.add(RxBus.INSTANCE
|
||||
.toObservable(EventInitializationChanged.class)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(event -> triggerNotificationUpdate(false),
|
||||
FabricPrivacy::logException
|
||||
));
|
||||
triggerNotificationUpdate(true);
|
||||
}
|
||||
|
||||
|
@ -331,9 +337,4 @@ public class PersistentNotificationPlugin extends PluginBase {
|
|||
triggerNotificationUpdate(false);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventInitializationChanged ev) {
|
||||
triggerNotificationUpdate(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -116,6 +116,12 @@ public class StatuslinePlugin extends PluginBase {
|
|||
.subscribe(event -> sendStatus(),
|
||||
FabricPrivacy::logException
|
||||
));
|
||||
disposable.add(RxBus.INSTANCE
|
||||
.toObservable(EventConfigBuilderChange.class)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(event -> sendStatus(),
|
||||
FabricPrivacy::logException
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -211,9 +217,4 @@ public class StatuslinePlugin extends PluginBase {
|
|||
sendStatus();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventConfigBuilderChange ev) {
|
||||
sendStatus();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package info.nightscout.androidaps.plugins.iob.iobCobCalculator;
|
||||
|
||||
import android.os.SystemClock;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.collection.LongSparseArray;
|
||||
|
@ -31,16 +32,20 @@ import info.nightscout.androidaps.interfaces.PluginBase;
|
|||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventNewHistoryData;
|
||||
import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin;
|
||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin;
|
||||
import info.nightscout.androidaps.plugins.treatments.Treatment;
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||
import info.nightscout.androidaps.utils.DateUtil;
|
||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||
import info.nightscout.androidaps.utils.T;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
import static info.nightscout.androidaps.utils.DateUtil.now;
|
||||
|
||||
|
@ -50,6 +55,7 @@ import static info.nightscout.androidaps.utils.DateUtil.now;
|
|||
|
||||
public class IobCobCalculatorPlugin extends PluginBase {
|
||||
private Logger log = LoggerFactory.getLogger(L.AUTOSENS);
|
||||
private CompositeDisposable disposable = new CompositeDisposable();
|
||||
|
||||
private static IobCobCalculatorPlugin plugin = null;
|
||||
|
||||
|
@ -83,14 +89,34 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
|||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
MainApp.bus().register(this);
|
||||
super.onStart();
|
||||
MainApp.bus().register(this);
|
||||
disposable.add(RxBus.INSTANCE
|
||||
.toObservable(EventConfigBuilderChange.class)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(event -> {
|
||||
if (this != getPlugin()) {
|
||||
if (L.isEnabled(L.AUTOSENS))
|
||||
log.debug("Ignoring event for non default instance");
|
||||
return;
|
||||
}
|
||||
stopCalculation("onEventConfigBuilderChange");
|
||||
synchronized (dataLock) {
|
||||
if (L.isEnabled(L.AUTOSENS))
|
||||
log.debug("Invalidating cached data because of configuration change. IOB: " + iobTable.size() + " Autosens: " + autosensDataTable.size() + " records");
|
||||
iobTable = new LongSparseArray<>();
|
||||
autosensDataTable = new LongSparseArray<>();
|
||||
}
|
||||
runCalculation("onEventConfigBuilderChange", System.currentTimeMillis(), false, true, event);
|
||||
}, FabricPrivacy::logException)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
disposable.clear();
|
||||
MainApp.bus().unregister(this);
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
public LongSparseArray<AutosensData> getAutosensDataTable() {
|
||||
|
@ -725,23 +751,6 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
|||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onEventConfigBuilderChange(EventConfigBuilderChange ev) {
|
||||
if (this != getPlugin()) {
|
||||
if (L.isEnabled(L.AUTOSENS))
|
||||
log.debug("Ignoring event for non default instance");
|
||||
return;
|
||||
}
|
||||
stopCalculation("onEventConfigBuilderChange");
|
||||
synchronized (dataLock) {
|
||||
if (L.isEnabled(L.AUTOSENS))
|
||||
log.debug("Invalidating cached data because of configuration change. IOB: " + iobTable.size() + " Autosens: " + autosensDataTable.size() + " records");
|
||||
iobTable = new LongSparseArray<>();
|
||||
autosensDataTable = new LongSparseArray<>();
|
||||
}
|
||||
runCalculation("onEventConfigBuilderChange", System.currentTimeMillis(), false, true, ev);
|
||||
}
|
||||
|
||||
// When historical data is changed (comming from NS etc) finished calculations after this date must be invalidated
|
||||
@Subscribe
|
||||
public void onEventNewHistoryData(EventNewHistoryData ev) {
|
||||
|
|
|
@ -13,8 +13,7 @@ import android.widget.RadioButton;
|
|||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.squareup.otto.Subscribe;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
|
@ -23,19 +22,24 @@ import info.nightscout.androidaps.R;
|
|||
import info.nightscout.androidaps.data.ProfileStore;
|
||||
import info.nightscout.androidaps.events.EventInitializationChanged;
|
||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||
import info.nightscout.androidaps.plugins.common.SubscriberFragment;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.general.careportal.CareportalFragment;
|
||||
import info.nightscout.androidaps.plugins.general.careportal.Dialogs.NewNSTreatmentDialog;
|
||||
import info.nightscout.androidaps.plugins.general.careportal.OptionsToShow;
|
||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||
import info.nightscout.androidaps.utils.NumberPicker;
|
||||
import info.nightscout.androidaps.utils.SafeParse;
|
||||
import info.nightscout.androidaps.utils.TimeListEdit;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
|
||||
import static info.nightscout.androidaps.plugins.insulin.InsulinOrefBasePlugin.MIN_DIA;
|
||||
|
||||
public class LocalProfileFragment extends SubscriberFragment {
|
||||
public class LocalProfileFragment extends Fragment {
|
||||
private CompositeDisposable disposable = new CompositeDisposable();
|
||||
|
||||
private NumberPicker diaView;
|
||||
private RadioButton mgdlView;
|
||||
private RadioButton mmolView;
|
||||
|
@ -143,6 +147,23 @@ public class LocalProfileFragment extends SubscriberFragment {
|
|||
return layout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void onResume() {
|
||||
super.onResume();
|
||||
disposable.add(RxBus.INSTANCE
|
||||
.toObservable(EventInitializationChanged.class)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(event -> updateGUI(), FabricPrivacy::logException)
|
||||
);
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void onPause() {
|
||||
super.onPause();
|
||||
disposable.clear();
|
||||
}
|
||||
|
||||
public void doEdit() {
|
||||
LocalProfilePlugin.getPlugin().setEdited(true);
|
||||
updateGUI();
|
||||
|
@ -157,12 +178,6 @@ public class LocalProfileFragment extends SubscriberFragment {
|
|||
return MainApp.gs(R.string.localprofile);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventInitializationChanged e) {
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateGUI() {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package info.nightscout.androidaps.plugins.profile.simple;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
|
@ -13,19 +12,24 @@ import android.widget.EditText;
|
|||
import android.widget.RadioButton;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.squareup.otto.Subscribe;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.events.EventInitializationChanged;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.general.careportal.CareportalFragment;
|
||||
import info.nightscout.androidaps.plugins.general.careportal.Dialogs.NewNSTreatmentDialog;
|
||||
import info.nightscout.androidaps.plugins.general.careportal.OptionsToShow;
|
||||
import info.nightscout.androidaps.plugins.common.SubscriberFragment;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||
import info.nightscout.androidaps.utils.SafeParse;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
|
||||
public class SimpleProfileFragment extends Fragment {
|
||||
private CompositeDisposable disposable = new CompositeDisposable();
|
||||
|
||||
public class SimpleProfileFragment extends SubscriberFragment {
|
||||
EditText diaView;
|
||||
RadioButton mgdlView;
|
||||
RadioButton mmolView;
|
||||
|
@ -122,16 +126,24 @@ public class SimpleProfileFragment extends SubscriberFragment {
|
|||
return layout;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventInitializationChanged e) {
|
||||
@Override
|
||||
public synchronized void onResume() {
|
||||
super.onResume();
|
||||
disposable.add(RxBus.INSTANCE
|
||||
.toObservable(EventInitializationChanged.class)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(event -> updateGUI(), FabricPrivacy::logException)
|
||||
);
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void onPause() {
|
||||
super.onPause();
|
||||
disposable.clear();
|
||||
}
|
||||
|
||||
protected void updateGUI() {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null)
|
||||
activity.runOnUiThread(() -> {
|
||||
boolean isValid = SimpleProfilePlugin.getPlugin().getProfile() != null && SimpleProfilePlugin.getPlugin().getProfile().getDefaultProfile().isValid(MainApp.gs(R.string.simpleprofile));
|
||||
if (!ConfigBuilderPlugin.getPlugin().getActivePump().isInitialized() || ConfigBuilderPlugin.getPlugin().getActivePump().isSuspended() || !isValid) {
|
||||
profileswitchButton.setVisibility(View.GONE);
|
||||
|
@ -142,7 +154,6 @@ public class SimpleProfileFragment extends SubscriberFragment {
|
|||
invalidProfile.setVisibility(View.GONE);
|
||||
else
|
||||
invalidProfile.setVisibility(View.VISIBLE);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -375,7 +375,6 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
|||
setValidBasalRateProfileSelectedOnPump(true);
|
||||
|
||||
pump.initialized = true;
|
||||
MainApp.bus().post(new EventInitializationChanged());
|
||||
RxBus.INSTANCE.send(new EventInitializationChanged());
|
||||
|
||||
// show notification to check pump date if last bolus is older than 24 hours
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.activities;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.widget.Button;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.Switch;
|
||||
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -21,12 +18,16 @@ import info.nightscout.androidaps.activities.NoSplashActivity;
|
|||
import info.nightscout.androidaps.events.EventInitializationChanged;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin;
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump;
|
||||
import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin;
|
||||
import info.nightscout.androidaps.plugins.pump.danaRv2.DanaRv2Plugin;
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||
import info.nightscout.androidaps.utils.NumberPicker;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 5/31/2018.
|
||||
|
@ -34,6 +35,7 @@ import info.nightscout.androidaps.utils.NumberPicker;
|
|||
|
||||
public class DanaRUserOptionsActivity extends NoSplashActivity {
|
||||
private static Logger log = LoggerFactory.getLogger(L.PUMP);
|
||||
private CompositeDisposable disposable = new CompositeDisposable();
|
||||
|
||||
Switch timeFormat;
|
||||
Switch buttonScroll;
|
||||
|
@ -54,15 +56,19 @@ public class DanaRUserOptionsActivity extends NoSplashActivity {
|
|||
boolean isDanaRv2 = MainApp.getSpecificPlugin(DanaRv2Plugin.class) != null && MainApp.getSpecificPlugin(DanaRv2Plugin.class).isEnabled(PluginType.PUMP);
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
protected synchronized void onResume() {
|
||||
super.onResume();
|
||||
MainApp.bus().register(this);
|
||||
disposable.add(RxBus.INSTANCE
|
||||
.toObservable(EventInitializationChanged.class)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(event -> setData(), FabricPrivacy::logException)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
protected synchronized void onPause() {
|
||||
disposable.clear();
|
||||
super.onPause();
|
||||
MainApp.bus().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -144,11 +150,6 @@ public class DanaRUserOptionsActivity extends NoSplashActivity {
|
|||
lowReservoir.setValue((double) pump.lowReservoirRate);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onEventInitializationChanged(EventInitializationChanged ignored) {
|
||||
runOnUiThread(this::setData);
|
||||
}
|
||||
|
||||
public void onSaveClick() {
|
||||
if (!isRS && !isDanaR && !isDanaRv2) {
|
||||
//exit if pump is not DanaRS, Dana!, or DanaR with upgraded firmware
|
||||
|
|
|
@ -193,7 +193,6 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
|||
danaRPump.lastConnection = 0;
|
||||
danaRPump.lastSettingsRead = 0;
|
||||
RxBus.INSTANCE.send(new EventDanaRNewStatus());
|
||||
MainApp.bus().post(new EventInitializationChanged());
|
||||
RxBus.INSTANCE.send(new EventInitializationChanged());
|
||||
return;
|
||||
}
|
||||
|
@ -211,7 +210,6 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
|||
}
|
||||
|
||||
RxBus.INSTANCE.send(new EventDanaRNewStatus());
|
||||
MainApp.bus().post(new EventInitializationChanged());
|
||||
RxBus.INSTANCE.send(new EventInitializationChanged());
|
||||
NSUpload.uploadDeviceStatus();
|
||||
if (danaRPump.dailyTotalUnits > danaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
|
||||
|
|
|
@ -194,7 +194,6 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
|||
danaRPump.lastConnection = 0;
|
||||
danaRPump.lastSettingsRead = 0;
|
||||
RxBus.INSTANCE.send(new EventDanaRNewStatus());
|
||||
MainApp.bus().post(new EventInitializationChanged());
|
||||
RxBus.INSTANCE.send(new EventInitializationChanged());
|
||||
return;
|
||||
}
|
||||
|
@ -214,7 +213,6 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
|||
}
|
||||
|
||||
RxBus.INSTANCE.send(new EventDanaRNewStatus());
|
||||
MainApp.bus().post(new EventInitializationChanged());
|
||||
RxBus.INSTANCE.send(new EventInitializationChanged());
|
||||
NSUpload.uploadDeviceStatus();
|
||||
if (danaRPump.dailyTotalUnits > danaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
|
||||
|
|
|
@ -163,7 +163,6 @@ public class DanaRSService extends Service {
|
|||
// deinitialize pump
|
||||
danaRPump.lastConnection = 0;
|
||||
RxBus.INSTANCE.send(new EventDanaRNewStatus());
|
||||
MainApp.bus().post(new EventInitializationChanged());
|
||||
RxBus.INSTANCE.send(new EventInitializationChanged());
|
||||
return;
|
||||
}
|
||||
|
@ -184,7 +183,6 @@ public class DanaRSService extends Service {
|
|||
//deinitialize pump
|
||||
danaRPump.lastConnection = 0;
|
||||
RxBus.INSTANCE.send(new EventDanaRNewStatus());
|
||||
MainApp.bus().post(new EventInitializationChanged());
|
||||
RxBus.INSTANCE.send(new EventInitializationChanged());
|
||||
return;
|
||||
} else {
|
||||
|
@ -214,8 +212,7 @@ public class DanaRSService extends Service {
|
|||
|
||||
loadEvents();
|
||||
|
||||
MainApp.bus().post(new EventDanaRNewStatus());
|
||||
MainApp.bus().post(new EventInitializationChanged());
|
||||
RxBus.INSTANCE.send(new EventDanaRNewStatus());
|
||||
RxBus.INSTANCE.send(new EventInitializationChanged());
|
||||
NSUpload.uploadDeviceStatus();
|
||||
if (danaRPump.dailyTotalUnits > danaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
|
||||
|
|
|
@ -202,7 +202,6 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
|||
danaRPump.lastConnection = 0;
|
||||
danaRPump.lastSettingsRead = 0;
|
||||
RxBus.INSTANCE.send(new EventDanaRNewStatus());
|
||||
MainApp.bus().post(new EventInitializationChanged());
|
||||
RxBus.INSTANCE.send(new EventInitializationChanged());
|
||||
return;
|
||||
}
|
||||
|
@ -224,7 +223,6 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
|||
//deinitialize pump
|
||||
danaRPump.lastConnection = 0;
|
||||
RxBus.INSTANCE.send(new EventDanaRNewStatus());
|
||||
MainApp.bus().post(new EventInitializationChanged());
|
||||
RxBus.INSTANCE.send(new EventInitializationChanged());
|
||||
return;
|
||||
} else {
|
||||
|
@ -258,7 +256,6 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
|||
loadEvents();
|
||||
|
||||
RxBus.INSTANCE.send(new EventDanaRNewStatus());
|
||||
MainApp.bus().post(new EventInitializationChanged());
|
||||
RxBus.INSTANCE.send(new EventInitializationChanged());
|
||||
NSUpload.uploadDeviceStatus();
|
||||
if (danaRPump.dailyTotalUnits > danaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
|
||||
|
|
|
@ -148,7 +148,6 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
|||
alertService = ((InsightAlertService.LocalBinder) binder).getService();
|
||||
}
|
||||
if (connectionService != null && alertService != null) {
|
||||
MainApp.bus().post(new EventInitializationChanged());
|
||||
RxBus.INSTANCE.send(new EventInitializationChanged());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package info.nightscout.androidaps.plugins.treatments.fragments;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.Paint;
|
||||
|
@ -13,30 +12,33 @@ import android.widget.TextView;
|
|||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.cardview.widget.CardView;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.db.CareportalEvent;
|
||||
import info.nightscout.androidaps.events.EventCareportalEventChange;
|
||||
import info.nightscout.androidaps.plugins.common.SubscriberFragment;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.UploadQueue;
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientRestart;
|
||||
import info.nightscout.androidaps.utils.DateUtil;
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
import info.nightscout.androidaps.utils.Translator;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
|
||||
/**
|
||||
* Created by mike on 13/01/17.
|
||||
*/
|
||||
|
||||
public class TreatmentsCareportalFragment extends SubscriberFragment implements View.OnClickListener {
|
||||
public class TreatmentsCareportalFragment extends Fragment implements View.OnClickListener {
|
||||
private CompositeDisposable disposable = new CompositeDisposable();
|
||||
|
||||
RecyclerView recyclerView;
|
||||
LinearLayoutManager llm;
|
||||
|
@ -148,10 +150,26 @@ public class TreatmentsCareportalFragment extends SubscriberFragment implements
|
|||
if (nsUploadOnly)
|
||||
refreshFromNS.setVisibility(View.GONE);
|
||||
|
||||
updateGUI();
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void onResume() {
|
||||
super.onResume();
|
||||
disposable.add(RxBus.INSTANCE
|
||||
.toObservable(EventCareportalEventChange.class)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(event -> updateGui(), FabricPrivacy::logException)
|
||||
);
|
||||
updateGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void onPause() {
|
||||
super.onPause();
|
||||
disposable.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
|
@ -182,22 +200,9 @@ public class TreatmentsCareportalFragment extends SubscriberFragment implements
|
|||
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventCareportalEventChange ev) {
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateGUI() {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null)
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
private void updateGui() {
|
||||
recyclerView.swapAdapter(new RecyclerViewAdapter(MainApp.getDbHelper().getCareportalEvents(false)), false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void removeAndroidAPSStatedEvents() {
|
||||
List<CareportalEvent> events = MainApp.getDbHelper().getCareportalEvents(false);
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.slf4j.LoggerFactory;
|
|||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.events.EventNetworkChange;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||
|
||||
public class NetworkChangeReceiver extends BroadcastReceiver {
|
||||
|
||||
|
@ -27,7 +28,7 @@ public class NetworkChangeReceiver extends BroadcastReceiver {
|
|||
public void onReceive(final Context context, final Intent intent) {
|
||||
EventNetworkChange event = grabNetworkStatus(context);
|
||||
if (event != null)
|
||||
MainApp.bus().post(event);
|
||||
RxBus.INSTANCE.send(event);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -40,23 +41,23 @@ public class NetworkChangeReceiver extends BroadcastReceiver {
|
|||
|
||||
if (activeNetwork != null) {
|
||||
if (activeNetwork.getType() == ConnectivityManager.TYPE_WIFI && activeNetwork.isConnected()) {
|
||||
event.wifiConnected = true;
|
||||
event.setWifiConnected(true);
|
||||
WifiManager wifiManager = (WifiManager) MainApp.instance().getApplicationContext().getSystemService(Context.WIFI_SERVICE);
|
||||
if (wifiManager != null) {
|
||||
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
|
||||
if (wifiInfo.getSupplicantState() == SupplicantState.COMPLETED) {
|
||||
event.ssid = wifiInfo.getSSID();
|
||||
event.setSsid(wifiInfo.getSSID());
|
||||
}
|
||||
if (L.isEnabled(L.CORE))
|
||||
log.debug("NETCHANGE: Wifi connected. SSID: " + event.ssid);
|
||||
log.debug("NETCHANGE: Wifi connected. SSID: " + event.connectedSsid());
|
||||
}
|
||||
}
|
||||
|
||||
if (activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE) {
|
||||
event.mobileConnected = true;
|
||||
event.roaming = activeNetwork.isRoaming();
|
||||
event.setMobileConnected(true);
|
||||
event.setRoaming(activeNetwork.isRoaming());
|
||||
if (L.isEnabled(L.CORE))
|
||||
log.debug("NETCHANGE: Mobile connected. Roaming: " + event.roaming);
|
||||
log.debug("NETCHANGE: Mobile connected. Roaming: " + event.getRoaming());
|
||||
}
|
||||
} else {
|
||||
if (L.isEnabled(L.CORE))
|
||||
|
@ -68,11 +69,11 @@ public class NetworkChangeReceiver extends BroadcastReceiver {
|
|||
}
|
||||
|
||||
public static boolean isWifiConnected() {
|
||||
return lastEvent != null && lastEvent.wifiConnected;
|
||||
return lastEvent != null && lastEvent.getWifiConnected();
|
||||
}
|
||||
|
||||
public static boolean isConnected() {
|
||||
return lastEvent != null && (lastEvent.wifiConnected || lastEvent.mobileConnected);
|
||||
return lastEvent != null && (lastEvent.getWifiConnected() || lastEvent.getMobileConnected());
|
||||
}
|
||||
|
||||
public static EventNetworkChange getLastEvent() {
|
||||
|
|
|
@ -19,6 +19,7 @@ import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
|||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesFragment;
|
||||
|
@ -170,7 +171,7 @@ public class SWDefinition {
|
|||
NSClientPlugin.getPlugin().setFragmentVisible(PluginType.GENERAL, true);
|
||||
ConfigBuilderPlugin.getPlugin().processOnEnabledCategoryChanged(NSClientPlugin.getPlugin(), PluginType.GENERAL);
|
||||
ConfigBuilderPlugin.getPlugin().storeSettings("SetupWizard");
|
||||
MainApp.bus().post(new EventConfigBuilderChange());
|
||||
RxBus.INSTANCE.send(new EventConfigBuilderChange());
|
||||
MainApp.bus().post(new EventSWUpdate(true));
|
||||
})
|
||||
.visibility(() -> !NSClientPlugin.getPlugin().isEnabled(PluginType.GENERAL)))
|
||||
|
@ -372,7 +373,7 @@ public class SWDefinition {
|
|||
LoopPlugin.getPlugin().setFragmentVisible(PluginType.LOOP, true);
|
||||
ConfigBuilderPlugin.getPlugin().processOnEnabledCategoryChanged(LoopPlugin.getPlugin(), PluginType.LOOP);
|
||||
ConfigBuilderPlugin.getPlugin().storeSettings("SetupWizard");
|
||||
MainApp.bus().post(new EventConfigBuilderChange());
|
||||
RxBus.INSTANCE.send(new EventConfigBuilderChange());
|
||||
MainApp.bus().post(new EventSWUpdate(true));
|
||||
})
|
||||
.visibility(() -> !LoopPlugin.getPlugin().isEnabled(PluginType.LOOP)))
|
||||
|
|
|
@ -17,7 +17,7 @@ import info.nightscout.androidaps.MainApp;
|
|||
import info.nightscout.androidaps.events.EventConfigBuilderChange;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderFragment;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.setupwizard.events.EventSWUpdate;
|
||||
|
||||
|
@ -88,7 +88,7 @@ public class SWPlugin extends SWItem {
|
|||
plugin.setFragmentVisible(pType, rb.isChecked() && makeVisible);
|
||||
ConfigBuilderPlugin.getPlugin().processOnEnabledCategoryChanged(plugin, pType);
|
||||
ConfigBuilderPlugin.getPlugin().storeSettings("SetupWizard");
|
||||
MainApp.bus().post(new EventConfigBuilderChange());
|
||||
RxBus.INSTANCE.send(new EventConfigBuilderChange());
|
||||
MainApp.bus().post(new EventSWUpdate());
|
||||
});
|
||||
layout.addView(radioGroup);
|
||||
|
|
|
@ -36,22 +36,22 @@ public class TriggerWifiSsidTest {
|
|||
|
||||
TriggerWifiSsid t = new TriggerWifiSsid().setValue("aSSID").comparator(Comparator.Compare.IS_EQUAL);
|
||||
|
||||
e.wifiConnected = false;
|
||||
e.setWifiConnected(false);
|
||||
Assert.assertFalse(t.shouldRun());
|
||||
|
||||
e.wifiConnected = true;
|
||||
e.ssid = "otherSSID";
|
||||
e.setWifiConnected(true);
|
||||
e.setSsid("otherSSID");
|
||||
Assert.assertFalse(t.shouldRun());
|
||||
|
||||
e.wifiConnected = true;
|
||||
e.ssid = "aSSID";
|
||||
e.setWifiConnected(true);
|
||||
e.setSsid("aSSID");
|
||||
Assert.assertTrue(t.shouldRun());
|
||||
|
||||
t.lastRun(now - 1);
|
||||
Assert.assertFalse(t.shouldRun());
|
||||
|
||||
t = new TriggerWifiSsid().setValue("aSSID").comparator(Comparator.Compare.IS_NOT_AVAILABLE);
|
||||
e.wifiConnected = false;
|
||||
e.setWifiConnected(false);
|
||||
Assert.assertTrue(t.shouldRun());
|
||||
|
||||
// no network data
|
||||
|
|
|
@ -64,67 +64,67 @@ public class NsClientReceiverDelegateTest {
|
|||
when(SP.getBoolean(anyInt(), anyBoolean())).thenReturn(false);
|
||||
when(SP.getString(anyInt(), anyString())).thenReturn("");
|
||||
EventNetworkChange ev = new EventNetworkChange();
|
||||
ev.ssid = "<unknown ssid>";
|
||||
ev.setSsid("<unknown ssid>");
|
||||
|
||||
ev.mobileConnected = true;
|
||||
ev.wifiConnected = true;
|
||||
ev.setMobileConnected(true);
|
||||
ev.setWifiConnected(true);
|
||||
assertTrue(sut.calculateStatus(ev));
|
||||
|
||||
ev.ssid = "test";
|
||||
ev.setSsid("test");
|
||||
when(SP.getString(anyInt(), anyString())).thenReturn("\"test\"");
|
||||
assertTrue(sut.calculateStatus(ev));
|
||||
|
||||
ev.ssid = "\"test\"";
|
||||
ev.setSsid("\"test\"");
|
||||
assertTrue(sut.calculateStatus(ev));
|
||||
|
||||
ev.wifiConnected = false;
|
||||
ev.setWifiConnected(false);
|
||||
assertTrue(sut.calculateStatus(ev));
|
||||
|
||||
// wifiOnly = true
|
||||
// allowRoaming = true as well
|
||||
when(SP.getBoolean(anyInt(), anyBoolean())).thenReturn(true);
|
||||
ev.wifiConnected = true;
|
||||
ev.setWifiConnected(true);
|
||||
assertTrue(sut.calculateStatus(ev));
|
||||
ev.wifiConnected = false;
|
||||
ev.setWifiConnected(false);
|
||||
assertTrue(!sut.calculateStatus(ev));
|
||||
|
||||
// wifiOnly = false
|
||||
// allowRoaming = false as well
|
||||
when(SP.getBoolean(anyInt(), anyBoolean())).thenReturn(false);
|
||||
ev.wifiConnected = false;
|
||||
ev.roaming = true;
|
||||
ev.setWifiConnected(false);
|
||||
ev.setRoaming(true);
|
||||
assertTrue(!sut.calculateStatus(ev));
|
||||
|
||||
// wifiOnly = false
|
||||
// allowRoaming = true
|
||||
when(SP.getBoolean(R.string.key_ns_wifionly, false)).thenReturn(false);
|
||||
when(SP.getBoolean(R.string.key_ns_allowroaming, true)).thenReturn(true);
|
||||
ev.wifiConnected = false;
|
||||
ev.roaming = true;
|
||||
ev.setWifiConnected(false);
|
||||
ev.setRoaming(true);
|
||||
assertTrue(sut.calculateStatus(ev));
|
||||
|
||||
// wifiOnly = true
|
||||
// allowRoaming = true
|
||||
when(SP.getBoolean(R.string.key_ns_wifionly, false)).thenReturn(true);
|
||||
when(SP.getBoolean(R.string.key_ns_allowroaming, true)).thenReturn(true);
|
||||
ev.wifiConnected = false;
|
||||
ev.roaming = true;
|
||||
ev.setWifiConnected(false);
|
||||
ev.setRoaming(true);
|
||||
assertTrue(!sut.calculateStatus(ev));
|
||||
|
||||
// wifiOnly = true
|
||||
// allowRoaming = true
|
||||
when(SP.getBoolean(R.string.key_ns_wifionly, false)).thenReturn(true);
|
||||
when(SP.getBoolean(R.string.key_ns_allowroaming, true)).thenReturn(true);
|
||||
ev.wifiConnected = true;
|
||||
ev.roaming = true;
|
||||
ev.setWifiConnected(true);
|
||||
ev.setRoaming(true);
|
||||
assertTrue(sut.calculateStatus(ev));
|
||||
|
||||
// wifiOnly = false
|
||||
// allowRoaming = false
|
||||
when(SP.getBoolean(R.string.key_ns_wifionly, false)).thenReturn(false);
|
||||
when(SP.getBoolean(R.string.key_ns_allowroaming, true)).thenReturn(false);
|
||||
ev.wifiConnected = true;
|
||||
ev.roaming = true;
|
||||
ev.setWifiConnected(true);
|
||||
ev.setRoaming(true);
|
||||
assertTrue(sut.calculateStatus(ev));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue