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