Events to RxBus
This commit is contained in:
parent
6044335b1d
commit
c42ef8e5ff
117 changed files with 368 additions and 753 deletions
|
@ -240,8 +240,6 @@ dependencies {
|
||||||
implementation 'androidx.percentlayout:percentlayout:1.0.0'
|
implementation 'androidx.percentlayout:percentlayout:1.0.0'
|
||||||
implementation "com.wdullaer:materialdatetimepicker:2.3.0"
|
implementation "com.wdullaer:materialdatetimepicker:2.3.0"
|
||||||
|
|
||||||
// Otto bus will be replaced by rx
|
|
||||||
implementation "com.squareup:otto:1.3.7"
|
|
||||||
implementation "io.reactivex.rxjava2:rxandroid:2.1.1"
|
implementation "io.reactivex.rxjava2:rxandroid:2.1.1"
|
||||||
|
|
||||||
implementation "com.j256.ormlite:ormlite-core:${ormLiteVersion}"
|
implementation "com.j256.ormlite:ormlite-core:${ormLiteVersion}"
|
||||||
|
|
|
@ -1,96 +0,0 @@
|
||||||
package com.squareup.otto;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.ConcurrentModificationException;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.events.Event;
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Logs events has they're being posted to and dispatched from the event bus.
|
|
||||||
* <p>
|
|
||||||
* A summary of event-receiver calls that occurred so far is logged
|
|
||||||
* after 10s (after startup) and then again every 60s.
|
|
||||||
*/
|
|
||||||
public class LoggingBus extends Bus {
|
|
||||||
private static Logger log = LoggerFactory.getLogger(L.EVENTS);
|
|
||||||
|
|
||||||
private static long everyMinute = System.currentTimeMillis() + 10 * 1000;
|
|
||||||
private Map<String, Set<String>> event2Receiver = new HashMap<>();
|
|
||||||
|
|
||||||
public LoggingBus(ThreadEnforcer enforcer) {
|
|
||||||
super(enforcer);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void post(Object event) {
|
|
||||||
if (event instanceof DeadEvent) {
|
|
||||||
log.debug("Event has no receiver: " + ((DeadEvent) event).event + ", source: " + ((DeadEvent) event).source);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(event instanceof Event)) {
|
|
||||||
log.error("Posted event not an event class: " + event.getClass());
|
|
||||||
}
|
|
||||||
|
|
||||||
log.debug("<<< " + event);
|
|
||||||
try {
|
|
||||||
StackTraceElement caller = new Throwable().getStackTrace()[1];
|
|
||||||
String className = caller.getClassName();
|
|
||||||
className = className.substring(className.lastIndexOf(".") + 1);
|
|
||||||
log.debug(" source: " + className + "." + caller.getMethodName() + ":" + caller.getLineNumber());
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
log.debug(" source: <unknown>");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
super.post(event);
|
|
||||||
} catch (IllegalStateException ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void dispatch(Object event, EventHandler wrapper) {
|
|
||||||
try {
|
|
||||||
log.debug(">>> " + event);
|
|
||||||
Field methodField = wrapper.getClass().getDeclaredField("method");
|
|
||||||
methodField.setAccessible(true);
|
|
||||||
Method targetMethod = (Method) methodField.get(wrapper);
|
|
||||||
String className = targetMethod.getDeclaringClass().getSimpleName();
|
|
||||||
String methodName = targetMethod.getName();
|
|
||||||
String receiverMethod = className + "." + methodName;
|
|
||||||
log.debug(" receiver: " + receiverMethod);
|
|
||||||
|
|
||||||
String key = event.getClass().getSimpleName();
|
|
||||||
if (!event2Receiver.containsKey(key)) event2Receiver.put(key, new HashSet<String>());
|
|
||||||
event2Receiver.get(key).add(receiverMethod);
|
|
||||||
} catch (ReflectiveOperationException e) {
|
|
||||||
log.debug(" receiver: <unknown>");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (everyMinute < System.currentTimeMillis()) {
|
|
||||||
log.debug("***************** Event -> receiver pairings seen so far ****************");
|
|
||||||
for (Map.Entry<String, Set<String>> stringSetEntry : event2Receiver.entrySet()) {
|
|
||||||
log.debug(" " + stringSetEntry.getKey());
|
|
||||||
for (String s : stringSetEntry.getValue()) {
|
|
||||||
log.debug(" -> " + s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
log.debug("*************************************************************************");
|
|
||||||
everyMinute = System.currentTimeMillis() + 60 * 1000;
|
|
||||||
}
|
|
||||||
} catch (ConcurrentModificationException ignored) {
|
|
||||||
}
|
|
||||||
|
|
||||||
super.dispatch(event, wrapper);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -143,7 +143,6 @@ public class MainActivity extends NoSplashAppCompatActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
MainApp.bus().register(this);
|
|
||||||
disposable.add(RxBus.INSTANCE
|
disposable.add(RxBus.INSTANCE
|
||||||
.toObservable(EventRefreshGui.class)
|
.toObservable(EventRefreshGui.class)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
@ -205,7 +204,6 @@ public class MainActivity extends NoSplashAppCompatActivity {
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
MainApp.bus().unregister(this);
|
|
||||||
disposable.clear();
|
disposable.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,9 +13,6 @@ import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||||
import com.crashlytics.android.Crashlytics;
|
import com.crashlytics.android.Crashlytics;
|
||||||
import com.google.firebase.analytics.FirebaseAnalytics;
|
import com.google.firebase.analytics.FirebaseAnalytics;
|
||||||
import com.j256.ormlite.android.apptools.OpenHelperManager;
|
import com.j256.ormlite.android.apptools.OpenHelperManager;
|
||||||
import com.squareup.otto.Bus;
|
|
||||||
import com.squareup.otto.LoggingBus;
|
|
||||||
import com.squareup.otto.ThreadEnforcer;
|
|
||||||
|
|
||||||
import net.danlew.android.joda.JodaTimeAndroid;
|
import net.danlew.android.joda.JodaTimeAndroid;
|
||||||
|
|
||||||
|
@ -101,7 +98,6 @@ public class MainApp extends Application {
|
||||||
private static Logger log = LoggerFactory.getLogger(L.CORE);
|
private static Logger log = LoggerFactory.getLogger(L.CORE);
|
||||||
private static KeepAliveReceiver keepAliveReceiver;
|
private static KeepAliveReceiver keepAliveReceiver;
|
||||||
|
|
||||||
private static Bus sBus;
|
|
||||||
private static MainApp sInstance;
|
private static MainApp sInstance;
|
||||||
public static Resources sResources;
|
public static Resources sResources;
|
||||||
|
|
||||||
|
@ -157,8 +153,6 @@ public class MainApp extends Application {
|
||||||
engineeringMode = engineeringModeSemaphore.exists() && engineeringModeSemaphore.isFile();
|
engineeringMode = engineeringModeSemaphore.exists() && engineeringModeSemaphore.isFile();
|
||||||
devBranch = BuildConfig.VERSION.contains("-") || BuildConfig.VERSION.matches(".*[a-zA-Z]+.*");
|
devBranch = BuildConfig.VERSION.contains("-") || BuildConfig.VERSION.matches(".*[a-zA-Z]+.*");
|
||||||
|
|
||||||
sBus = L.isEnabled(L.EVENTS) && devBranch ? new LoggingBus(ThreadEnforcer.ANY) : new Bus(ThreadEnforcer.ANY);
|
|
||||||
|
|
||||||
registerLocalBroadcastReceiver();
|
registerLocalBroadcastReceiver();
|
||||||
|
|
||||||
//trigger here to see the new version on app start after an update
|
//trigger here to see the new version on app start after an update
|
||||||
|
@ -285,10 +279,6 @@ public class MainApp extends Application {
|
||||||
KeepAliveReceiver.cancelAlarm(this);
|
KeepAliveReceiver.cancelAlarm(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Bus bus() {
|
|
||||||
return sBus;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String gs(int id) {
|
public static String gs(int id) {
|
||||||
return sResources.getString(id);
|
return sResources.getString(id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,6 @@ public class TDDStatsActivity extends NoSplashActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
MainApp.bus().register(this);
|
|
||||||
disposable.add(RxBus.INSTANCE
|
disposable.add(RxBus.INSTANCE
|
||||||
.toObservable(EventPumpStatusChanged.class)
|
.toObservable(EventPumpStatusChanged.class)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
@ -96,7 +95,6 @@ public class TDDStatsActivity extends NoSplashActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
MainApp.bus().unregister(this);
|
|
||||||
disposable.clear();
|
disposable.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,20 +5,19 @@ import android.os.SystemClock;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.fragment.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
|
||||||
import info.nightscout.androidaps.R;
|
|
||||||
import info.nightscout.androidaps.events.EventConfigBuilderChange;
|
|
||||||
import info.nightscout.androidaps.events.EventRefreshGui;
|
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.EventConfigBuilderUpdateGui;
|
|
||||||
import info.nightscout.androidaps.utils.SP;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.events.EventConfigBuilderChange;
|
||||||
|
import info.nightscout.androidaps.events.EventRefreshGui;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
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.plugins.configBuilder.EventConfigBuilderUpdateGui;
|
||||||
import info.nightscout.androidaps.queue.CommandQueue;
|
import info.nightscout.androidaps.queue.CommandQueue;
|
||||||
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 09.06.2016.
|
* Created by mike on 09.06.2016.
|
||||||
|
@ -82,7 +81,7 @@ public abstract class PluginBase {
|
||||||
ConfigBuilderPlugin.getPlugin().processOnEnabledCategoryChanged(this, getType());
|
ConfigBuilderPlugin.getPlugin().processOnEnabledCategoryChanged(this, getType());
|
||||||
ConfigBuilderPlugin.getPlugin().storeSettings("CheckedCheckboxEnabled");
|
ConfigBuilderPlugin.getPlugin().storeSettings("CheckedCheckboxEnabled");
|
||||||
RxBus.INSTANCE.send(new EventRefreshGui());
|
RxBus.INSTANCE.send(new EventRefreshGui());
|
||||||
MainApp.bus().post(new EventConfigBuilderChange());
|
RxBus.INSTANCE.send(new EventConfigBuilderChange());
|
||||||
RxBus.INSTANCE.send(new EventConfigBuilderUpdateGui());
|
RxBus.INSTANCE.send(new EventConfigBuilderUpdateGui());
|
||||||
ConfigBuilderPlugin.getPlugin().logPluginStatus();
|
ConfigBuilderPlugin.getPlugin().logPluginStatus();
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,6 @@ import android.os.SystemClock;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.core.app.NotificationCompat;
|
import androidx.core.app.NotificationCompat;
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -119,7 +117,6 @@ public class LoopPlugin extends PluginBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
MainApp.bus().register(this);
|
|
||||||
createNotificationChannel();
|
createNotificationChannel();
|
||||||
super.onStart();
|
super.onStart();
|
||||||
disposable.add(RxBus.INSTANCE
|
disposable.add(RxBus.INSTANCE
|
||||||
|
@ -169,7 +166,6 @@ public class LoopPlugin extends PluginBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop() {
|
protected void onStop() {
|
||||||
MainApp.bus().unregister(this);
|
|
||||||
disposable.clear();
|
disposable.clear();
|
||||||
super.onStop();
|
super.onStop();
|
||||||
}
|
}
|
||||||
|
@ -441,7 +437,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
(NotificationManager) MainApp.instance().getSystemService(Context.NOTIFICATION_SERVICE);
|
(NotificationManager) MainApp.instance().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
// mId allows you to update the notification later on.
|
// mId allows you to update the notification later on.
|
||||||
mNotificationManager.notify(Constants.notificationID, builder.build());
|
mNotificationManager.notify(Constants.notificationID, builder.build());
|
||||||
MainApp.bus().post(new EventNewOpenLoopNotification());
|
RxBus.INSTANCE.send(new EventNewOpenLoopNotification());
|
||||||
|
|
||||||
// Send to Wear
|
// Send to Wear
|
||||||
ActionStringHandler.handleInitiate("changeRequest");
|
ActionStringHandler.handleInitiate("changeRequest");
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.aps.loop.events;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.events.Event;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 07.08.2016.
|
|
||||||
*/
|
|
||||||
public class EventNewOpenLoopNotification extends Event {
|
|
||||||
}
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
package info.nightscout.androidaps.plugins.aps.loop.events
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.events.Event
|
||||||
|
|
||||||
|
class EventNewOpenLoopNotification : Event()
|
|
@ -1,22 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.common;
|
|
||||||
|
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
|
|
||||||
abstract public class SubscriberFragment extends Fragment {
|
|
||||||
@Override
|
|
||||||
public void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
MainApp.bus().unregister(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
MainApp.bus().register(this);
|
|
||||||
updateGUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract void updateGUI();
|
|
||||||
}
|
|
|
@ -68,14 +68,12 @@ public class ConfigBuilderPlugin extends PluginBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
MainApp.bus().register(this);
|
|
||||||
super.onStart();
|
super.onStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop() {
|
protected void onStop() {
|
||||||
super.onStop();
|
super.onStop();
|
||||||
MainApp.bus().unregister(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,6 @@ import android.os.IBinder;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -91,7 +89,7 @@ public class NSClientPlugin extends PluginBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
nsClientReceiverDelegate =
|
nsClientReceiverDelegate =
|
||||||
new NsClientReceiverDelegate(MainApp.instance().getApplicationContext(), MainApp.bus());
|
new NsClientReceiverDelegate(MainApp.instance().getApplicationContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAllowed() {
|
public boolean isAllowed() {
|
||||||
|
@ -101,7 +99,6 @@ public class NSClientPlugin extends PluginBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
MainApp.bus().register(this);
|
|
||||||
Context context = MainApp.instance().getApplicationContext();
|
Context context = MainApp.instance().getApplicationContext();
|
||||||
Intent intent = new Intent(context, NSClientService.class);
|
Intent intent = new Intent(context, NSClientService.class);
|
||||||
context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
|
context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
|
||||||
|
@ -145,24 +142,21 @@ public class NSClientPlugin extends PluginBase {
|
||||||
log.debug(event.getAction() + " " + event.getLogText());
|
log.debug(event.getAction() + " " + event.getLogText());
|
||||||
}, FabricPrivacy::logException)
|
}, FabricPrivacy::logException)
|
||||||
);
|
);
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventChargingState.class)
|
||||||
|
.observeOn(Schedulers.io())
|
||||||
|
.subscribe(event -> nsClientReceiverDelegate.onStatusEvent(event), FabricPrivacy::logException)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop() {
|
protected void onStop() {
|
||||||
MainApp.bus().unregister(this);
|
MainApp.instance().getApplicationContext().unbindService(mConnection);
|
||||||
Context context = MainApp.instance().getApplicationContext();
|
|
||||||
context.unbindService(mConnection);
|
|
||||||
|
|
||||||
nsClientReceiverDelegate.unregisterReceivers();
|
nsClientReceiverDelegate.unregisterReceivers();
|
||||||
disposable.clear();
|
disposable.clear();
|
||||||
super.onStop();
|
super.onStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(final EventChargingState ev) {
|
|
||||||
nsClientReceiverDelegate.onStatusEvent(ev);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ServiceConnection mConnection = new ServiceConnection() {
|
private ServiceConnection mConnection = new ServiceConnection() {
|
||||||
|
|
||||||
public void onServiceDisconnected(ComponentName name) {
|
public void onServiceDisconnected(ComponentName name) {
|
||||||
|
|
|
@ -6,14 +6,12 @@ import android.content.IntentFilter;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
|
|
||||||
import com.squareup.otto.Bus;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
|
||||||
import info.nightscout.androidaps.events.EventChargingState;
|
import info.nightscout.androidaps.events.EventChargingState;
|
||||||
import info.nightscout.androidaps.events.EventNetworkChange;
|
import info.nightscout.androidaps.events.EventNetworkChange;
|
||||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import info.nightscout.androidaps.receivers.ChargingStateReceiver;
|
import info.nightscout.androidaps.receivers.ChargingStateReceiver;
|
||||||
import info.nightscout.androidaps.receivers.NetworkChangeReceiver;
|
import info.nightscout.androidaps.receivers.NetworkChangeReceiver;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
@ -21,7 +19,6 @@ import info.nightscout.androidaps.utils.SP;
|
||||||
class NsClientReceiverDelegate {
|
class NsClientReceiverDelegate {
|
||||||
|
|
||||||
private final Context context;
|
private final Context context;
|
||||||
private final Bus bus;
|
|
||||||
|
|
||||||
private NetworkChangeReceiver networkChangeReceiver = new NetworkChangeReceiver();
|
private NetworkChangeReceiver networkChangeReceiver = new NetworkChangeReceiver();
|
||||||
private ChargingStateReceiver chargingStateReceiver = new ChargingStateReceiver();
|
private ChargingStateReceiver chargingStateReceiver = new ChargingStateReceiver();
|
||||||
|
@ -30,9 +27,8 @@ class NsClientReceiverDelegate {
|
||||||
private boolean allowedNetworkState = true;
|
private boolean allowedNetworkState = true;
|
||||||
boolean allowed = true;
|
boolean allowed = true;
|
||||||
|
|
||||||
NsClientReceiverDelegate(Context context, Bus bus) {
|
NsClientReceiverDelegate(Context context) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.bus = bus;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void registerReceivers() {
|
void registerReceivers() {
|
||||||
|
@ -53,7 +49,7 @@ class NsClientReceiverDelegate {
|
||||||
|
|
||||||
EventChargingState eventChargingState = chargingStateReceiver.grabChargingState(context);
|
EventChargingState eventChargingState = chargingStateReceiver.grabChargingState(context);
|
||||||
if (eventChargingState != null)
|
if (eventChargingState != null)
|
||||||
bus.post(eventChargingState);
|
RxBus.INSTANCE.send(eventChargingState);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,14 +62,14 @@ class NsClientReceiverDelegate {
|
||||||
if (ev.isChanged(R.string.key_ns_wifionly) ||
|
if (ev.isChanged(R.string.key_ns_wifionly) ||
|
||||||
ev.isChanged(R.string.key_ns_wifi_ssids) ||
|
ev.isChanged(R.string.key_ns_wifi_ssids) ||
|
||||||
ev.isChanged(R.string.key_ns_allowroaming)
|
ev.isChanged(R.string.key_ns_allowroaming)
|
||||||
) {
|
) {
|
||||||
EventNetworkChange event = networkChangeReceiver.grabNetworkStatus(MainApp.instance().getApplicationContext());
|
EventNetworkChange event = networkChangeReceiver.grabNetworkStatus(MainApp.instance().getApplicationContext());
|
||||||
if (event != null)
|
if (event != null)
|
||||||
RxBus.INSTANCE.send(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)
|
||||||
bus.post(event);
|
RxBus.INSTANCE.send(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.events.Event;
|
import info.nightscout.androidaps.events.Event;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
|
@ -34,7 +33,7 @@ public class NSAddAck extends Event implements Ack {
|
||||||
nsClientID = response.getString("NSCLIENT_ID");
|
nsClientID = response.getString("NSCLIENT_ID");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MainApp.bus().post(this);
|
RxBus.INSTANCE.send(this);
|
||||||
return;
|
return;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
|
|
|
@ -2,13 +2,10 @@ package info.nightscout.androidaps.plugins.general.nsclient.acks;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.events.Event;
|
import info.nightscout.androidaps.events.Event;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import io.socket.client.Ack;
|
import io.socket.client.Ack;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 02.01.2016.
|
|
||||||
*/
|
|
||||||
public class NSAuthAck extends Event implements Ack{
|
public class NSAuthAck extends Event implements Ack{
|
||||||
public boolean read = false;
|
public boolean read = false;
|
||||||
public boolean write = false;
|
public boolean write = false;
|
||||||
|
@ -19,6 +16,6 @@ public class NSAuthAck extends Event implements Ack{
|
||||||
read = response.optBoolean("read");
|
read = response.optBoolean("read");
|
||||||
write = response.optBoolean("write");
|
write = response.optBoolean("write");
|
||||||
write_treatment = response.optBoolean("write_treatment");
|
write_treatment = response.optBoolean("write_treatment");
|
||||||
MainApp.bus().post(this);
|
RxBus.INSTANCE.send(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.events.Event;
|
import info.nightscout.androidaps.events.Event;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import io.socket.client.Ack;
|
import io.socket.client.Ack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,7 +28,7 @@ public class NSUpdateAck extends Event implements Ack {
|
||||||
result = true;
|
result = true;
|
||||||
log.debug("Internal error: Missing _id returned on dbUpdate ack");
|
log.debug("Internal error: Missing _id returned on dbUpdate ack");
|
||||||
}
|
}
|
||||||
MainApp.bus().post(this);
|
RxBus.INSTANCE.send(this);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@ import android.os.SystemClock;
|
||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
import com.google.common.hash.Hashing;
|
import com.google.common.hash.Hashing;
|
||||||
import com.j256.ormlite.dao.CloseableIterator;
|
import com.j256.ormlite.dao.CloseableIterator;
|
||||||
import com.squareup.otto.Subscribe;
|
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
@ -116,7 +115,6 @@ public class NSClientService extends Service {
|
||||||
private int WATCHDOG_MAXCONNECTIONS = 5;
|
private int WATCHDOG_MAXCONNECTIONS = 5;
|
||||||
|
|
||||||
public NSClientService() {
|
public NSClientService() {
|
||||||
registerBus();
|
|
||||||
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();
|
||||||
|
@ -175,6 +173,21 @@ public class NSClientService extends Service {
|
||||||
restart();
|
restart();
|
||||||
}, FabricPrivacy::logException)
|
}, FabricPrivacy::logException)
|
||||||
);
|
);
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(NSAuthAck.class)
|
||||||
|
.observeOn(Schedulers.io())
|
||||||
|
.subscribe(event -> processAuthAck(event), FabricPrivacy::logException)
|
||||||
|
);
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(NSUpdateAck.class)
|
||||||
|
.observeOn(Schedulers.io())
|
||||||
|
.subscribe(event -> processUpdateAck(event), FabricPrivacy::logException)
|
||||||
|
);
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(NSAddAck.class)
|
||||||
|
.observeOn(Schedulers.io())
|
||||||
|
.subscribe(event -> processAddAck(event), FabricPrivacy::logException)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -184,6 +197,48 @@ public class NSClientService extends Service {
|
||||||
if (mWakeLock.isHeld()) mWakeLock.release();
|
if (mWakeLock.isHeld()) mWakeLock.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void processAddAck(NSAddAck ack) {
|
||||||
|
if (ack.nsClientID != null) {
|
||||||
|
uploadQueue.removeID(ack.json);
|
||||||
|
RxBus.INSTANCE.send(new EventNSClientNewLog("DBADD", "Acked " + ack.nsClientID));
|
||||||
|
} else {
|
||||||
|
RxBus.INSTANCE.send(new EventNSClientNewLog("ERROR", "DBADD Unknown response"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processUpdateAck(NSUpdateAck ack) {
|
||||||
|
if (ack.result) {
|
||||||
|
uploadQueue.removeID(ack.action, ack._id);
|
||||||
|
RxBus.INSTANCE.send(new EventNSClientNewLog("DBUPDATE/DBREMOVE", "Acked " + ack._id));
|
||||||
|
} else {
|
||||||
|
RxBus.INSTANCE.send(new EventNSClientNewLog("ERROR", "DBUPDATE/DBREMOVE Unknown response"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processAuthAck(NSAuthAck ack) {
|
||||||
|
String connectionStatus = "Authenticated (";
|
||||||
|
if (ack.read) connectionStatus += "R";
|
||||||
|
if (ack.write) connectionStatus += "W";
|
||||||
|
if (ack.write_treatment) connectionStatus += "T";
|
||||||
|
connectionStatus += ')';
|
||||||
|
isConnected = true;
|
||||||
|
hasWriteAuth = ack.write && ack.write_treatment;
|
||||||
|
RxBus.INSTANCE.send(new EventNSClientStatus(connectionStatus));
|
||||||
|
RxBus.INSTANCE.send(new EventNSClientNewLog("AUTH", connectionStatus));
|
||||||
|
if (!ack.write) {
|
||||||
|
RxBus.INSTANCE.send(new EventNSClientNewLog("ERROR", "Write permission not granted !!!!"));
|
||||||
|
}
|
||||||
|
if (!ack.write_treatment) {
|
||||||
|
RxBus.INSTANCE.send(new EventNSClientNewLog("ERROR", "Write treatment permission not granted !!!!"));
|
||||||
|
}
|
||||||
|
if (!hasWriteAuth) {
|
||||||
|
Notification noperm = new Notification(Notification.NSCLIENT_NO_WRITE_PERMISSION, MainApp.gs(R.string.nowritepermission), Notification.URGENT);
|
||||||
|
RxBus.INSTANCE.send(new EventNewNotification(noperm));
|
||||||
|
} else {
|
||||||
|
RxBus.INSTANCE.send(new EventDismissNotification(Notification.NSCLIENT_NO_WRITE_PERMISSION));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class LocalBinder extends Binder {
|
public class LocalBinder extends Binder {
|
||||||
public NSClientService getServiceInstance() {
|
public NSClientService getServiceInstance() {
|
||||||
return NSClientService.this;
|
return NSClientService.this;
|
||||||
|
@ -201,15 +256,6 @@ public class NSClientService extends Service {
|
||||||
return START_STICKY;
|
return START_STICKY;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerBus() {
|
|
||||||
try {
|
|
||||||
MainApp.bus().unregister(this);
|
|
||||||
} catch (RuntimeException x) {
|
|
||||||
// Ignore
|
|
||||||
}
|
|
||||||
MainApp.bus().register(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
dataCounter = 0;
|
dataCounter = 0;
|
||||||
|
|
||||||
|
@ -339,31 +385,6 @@ public class NSClientService extends Service {
|
||||||
mSocket.emit("authorize", authMessage, ack);
|
mSocket.emit("authorize", authMessage, ack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(NSAuthAck ack) {
|
|
||||||
String connectionStatus = "Authenticated (";
|
|
||||||
if (ack.read) connectionStatus += "R";
|
|
||||||
if (ack.write) connectionStatus += "W";
|
|
||||||
if (ack.write_treatment) connectionStatus += "T";
|
|
||||||
connectionStatus += ')';
|
|
||||||
isConnected = true;
|
|
||||||
hasWriteAuth = ack.write && ack.write_treatment;
|
|
||||||
RxBus.INSTANCE.send(new EventNSClientStatus(connectionStatus));
|
|
||||||
RxBus.INSTANCE.send(new EventNSClientNewLog("AUTH", connectionStatus));
|
|
||||||
if (!ack.write) {
|
|
||||||
RxBus.INSTANCE.send(new EventNSClientNewLog("ERROR", "Write permission not granted !!!!"));
|
|
||||||
}
|
|
||||||
if (!ack.write_treatment) {
|
|
||||||
RxBus.INSTANCE.send(new EventNSClientNewLog("ERROR", "Write treatment permission not granted !!!!"));
|
|
||||||
}
|
|
||||||
if (!hasWriteAuth) {
|
|
||||||
Notification noperm = new Notification(Notification.NSCLIENT_NO_WRITE_PERMISSION, MainApp.gs(R.string.nowritepermission), Notification.URGENT);
|
|
||||||
RxBus.INSTANCE.send(new EventNewNotification(noperm));
|
|
||||||
} else {
|
|
||||||
RxBus.INSTANCE.send(new EventDismissNotification(Notification.NSCLIENT_NO_WRITE_PERMISSION));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void readPreferences() {
|
public void readPreferences() {
|
||||||
nsEnabled = MainApp.getSpecificPlugin(NSClientPlugin.class).isEnabled(PluginType.GENERAL);
|
nsEnabled = MainApp.getSpecificPlugin(NSClientPlugin.class).isEnabled(PluginType.GENERAL);
|
||||||
nsURL = SP.getString(R.string.key_nsclientinternal_url, "");
|
nsURL = SP.getString(R.string.key_nsclientinternal_url, "");
|
||||||
|
@ -756,16 +777,6 @@ public class NSClientService extends Service {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(NSUpdateAck ack) {
|
|
||||||
if (ack.result) {
|
|
||||||
uploadQueue.removeID(ack.action, ack._id);
|
|
||||||
RxBus.INSTANCE.send(new EventNSClientNewLog("DBUPDATE/DBREMOVE", "Acked " + ack._id));
|
|
||||||
} else {
|
|
||||||
RxBus.INSTANCE.send(new EventNSClientNewLog("ERROR", "DBUPDATE/DBREMOVE Unknown response"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dbAdd(DbRequest dbr, NSAddAck ack) {
|
public void dbAdd(DbRequest dbr, NSAddAck ack) {
|
||||||
try {
|
try {
|
||||||
if (!isConnected || !hasWriteAuth) return;
|
if (!isConnected || !hasWriteAuth) return;
|
||||||
|
@ -785,16 +796,6 @@ public class NSClientService extends Service {
|
||||||
RxBus.INSTANCE.send(new EventNSClientNewLog("ALARMACK ", alarmAck.level + " " + alarmAck.group + " " + alarmAck.silenceTime));
|
RxBus.INSTANCE.send(new EventNSClientNewLog("ALARMACK ", alarmAck.level + " " + alarmAck.group + " " + alarmAck.silenceTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(NSAddAck ack) {
|
|
||||||
if (ack.nsClientID != null) {
|
|
||||||
uploadQueue.removeID(ack.json);
|
|
||||||
RxBus.INSTANCE.send(new EventNSClientNewLog("DBADD", "Acked " + ack.nsClientID));
|
|
||||||
} else {
|
|
||||||
RxBus.INSTANCE.send(new EventNSClientNewLog("ERROR", "DBADD Unknown response"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void resend(final String reason) {
|
public void resend(final String reason) {
|
||||||
if (UploadQueue.size() == 0)
|
if (UploadQueue.size() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -3,7 +3,6 @@ package info.nightscout.androidaps.plugins.general.overview;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
|
|
||||||
import android.content.ActivityNotFoundException;
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
@ -12,16 +11,6 @@ import android.graphics.Color;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
import androidx.fragment.app.FragmentActivity;
|
|
||||||
import androidx.fragment.app.FragmentManager;
|
|
||||||
import androidx.core.content.res.ResourcesCompat;
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
||||||
import androidx.appcompat.widget.PopupMenu;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
|
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.text.style.ForegroundColorSpan;
|
import android.text.style.ForegroundColorSpan;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
|
@ -36,8 +25,16 @@ import android.widget.ImageButton;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import androidx.appcompat.widget.PopupMenu;
|
||||||
|
import androidx.core.content.res.ResourcesCompat;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.jjoe64.graphview.GraphView;
|
import com.jjoe64.graphview.GraphView;
|
||||||
import com.squareup.otto.Subscribe;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -83,11 +80,9 @@ import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.APSResult;
|
import info.nightscout.androidaps.plugins.aps.loop.APSResult;
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin;
|
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin;
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.events.EventNewOpenLoopNotification;
|
import info.nightscout.androidaps.plugins.aps.loop.events.EventNewOpenLoopNotification;
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSMA.events.EventOpenAPSUpdateGui;
|
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
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.general.automation.events.EventAutomationUpdateGui;
|
|
||||||
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;
|
||||||
|
@ -125,7 +120,6 @@ import info.nightscout.androidaps.utils.T;
|
||||||
import info.nightscout.androidaps.utils.ToastUtils;
|
import info.nightscout.androidaps.utils.ToastUtils;
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
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;
|
||||||
|
|
||||||
|
@ -349,6 +343,117 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
disposable.clear();
|
||||||
|
sLoopHandler.removeCallbacksAndMessages(null);
|
||||||
|
unregisterForContextMenu(apsModeView);
|
||||||
|
unregisterForContextMenu(activeProfileView);
|
||||||
|
unregisterForContextMenu(tempTargetView);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventRefreshOverview.class)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(eventOpenAPSUpdateGui -> scheduleUpdateGUI(eventOpenAPSUpdateGui.getFrom()),
|
||||||
|
FabricPrivacy::logException
|
||||||
|
));
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventExtendedBolusChange.class)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(event -> scheduleUpdateGUI("EventExtendedBolusChange"),
|
||||||
|
FabricPrivacy::logException
|
||||||
|
));
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventTempBasalChange.class)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(event -> scheduleUpdateGUI("EventTempBasalChange"),
|
||||||
|
FabricPrivacy::logException
|
||||||
|
));
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventTreatmentChange.class)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(event -> scheduleUpdateGUI("EventTreatmentChange"),
|
||||||
|
FabricPrivacy::logException
|
||||||
|
));
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventTempTargetChange.class)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.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(EventAutosensCalculationFinished.class)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(event -> scheduleUpdateGUI("EventAutosensCalculationFinished"),
|
||||||
|
FabricPrivacy::logException
|
||||||
|
));
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventProfileNeedsUpdate.class)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(event -> scheduleUpdateGUI("EventProfileNeedsUpdate"),
|
||||||
|
FabricPrivacy::logException
|
||||||
|
));
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventPreferenceChange.class)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(event -> scheduleUpdateGUI("EventPreferenceChange"),
|
||||||
|
FabricPrivacy::logException
|
||||||
|
));
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventNewOpenLoopNotification.class)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(event -> scheduleUpdateGUI("EventNewOpenLoopNotification"),
|
||||||
|
FabricPrivacy::logException
|
||||||
|
));
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventPumpStatusChanged.class)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(event -> updatePumpStatus(event.getStatus()),
|
||||||
|
FabricPrivacy::logException
|
||||||
|
));
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventIobCalculationProgress.class)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(event -> {
|
||||||
|
if (iobCalculationProgressView != null)
|
||||||
|
iobCalculationProgressView.setText(event.getProgress());
|
||||||
|
},
|
||||||
|
FabricPrivacy::logException
|
||||||
|
));
|
||||||
|
sRefreshLoop = () -> {
|
||||||
|
scheduleUpdateGUI("refreshLoop");
|
||||||
|
sLoopHandler.postDelayed(sRefreshLoop, 60 * 1000L);
|
||||||
|
};
|
||||||
|
sLoopHandler.postDelayed(sRefreshLoop, 60 * 1000L);
|
||||||
|
registerForContextMenu(apsModeView);
|
||||||
|
registerForContextMenu(activeProfileView);
|
||||||
|
registerForContextMenu(tempTargetView);
|
||||||
|
updateGUI("onResume");
|
||||||
|
}
|
||||||
|
|
||||||
private void setupChartMenu(View view) {
|
private void setupChartMenu(View view) {
|
||||||
chartButton = (ImageButton) view.findViewById(R.id.overview_chartMenuButton);
|
chartButton = (ImageButton) view.findViewById(R.id.overview_chartMenuButton);
|
||||||
chartButton.setOnClickListener(v -> {
|
chartButton.setOnClickListener(v -> {
|
||||||
|
@ -548,8 +653,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showSuspendtPump(ContextMenu menu,
|
private void showSuspendtPump(ContextMenu menu, PumpDescription pumpDescription) {
|
||||||
PumpDescription pumpDescription) {
|
|
||||||
if (pumpDescription.tempDurationStep15mAllowed)
|
if (pumpDescription.tempDurationStep15mAllowed)
|
||||||
menu.add(MainApp.gs(R.string.disconnectpumpfor15m));
|
menu.add(MainApp.gs(R.string.disconnectpumpfor15m));
|
||||||
if (pumpDescription.tempDurationStep30mAllowed)
|
if (pumpDescription.tempDurationStep30mAllowed)
|
||||||
|
@ -855,118 +959,6 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
MainApp.bus().unregister(this);
|
|
||||||
disposable.clear();
|
|
||||||
sLoopHandler.removeCallbacksAndMessages(null);
|
|
||||||
unregisterForContextMenu(apsModeView);
|
|
||||||
unregisterForContextMenu(activeProfileView);
|
|
||||||
unregisterForContextMenu(tempTargetView);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
MainApp.bus().register(this);
|
|
||||||
disposable.add(RxBus.INSTANCE
|
|
||||||
.toObservable(EventRefreshOverview.class)
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe(eventOpenAPSUpdateGui -> scheduleUpdateGUI(eventOpenAPSUpdateGui.getFrom()),
|
|
||||||
FabricPrivacy::logException
|
|
||||||
));
|
|
||||||
disposable.add(RxBus.INSTANCE
|
|
||||||
.toObservable(EventExtendedBolusChange.class)
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe(event -> scheduleUpdateGUI("EventExtendedBolusChange"),
|
|
||||||
FabricPrivacy::logException
|
|
||||||
));
|
|
||||||
disposable.add(RxBus.INSTANCE
|
|
||||||
.toObservable(EventTempBasalChange.class)
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe(event -> scheduleUpdateGUI("EventTempBasalChange"),
|
|
||||||
FabricPrivacy::logException
|
|
||||||
));
|
|
||||||
disposable.add(RxBus.INSTANCE
|
|
||||||
.toObservable(EventTreatmentChange.class)
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe(event -> scheduleUpdateGUI("EventTreatmentChange"),
|
|
||||||
FabricPrivacy::logException
|
|
||||||
));
|
|
||||||
disposable.add(RxBus.INSTANCE
|
|
||||||
.toObservable(EventTempTargetChange.class)
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.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(EventAutosensCalculationFinished.class)
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe(event -> scheduleUpdateGUI("EventAutosensCalculationFinished"),
|
|
||||||
FabricPrivacy::logException
|
|
||||||
));
|
|
||||||
disposable.add(RxBus.INSTANCE
|
|
||||||
.toObservable(EventProfileNeedsUpdate.class)
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe(event -> scheduleUpdateGUI("EventProfileNeedsUpdate"),
|
|
||||||
FabricPrivacy::logException
|
|
||||||
));
|
|
||||||
disposable.add(RxBus.INSTANCE
|
|
||||||
.toObservable(EventPreferenceChange.class)
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe(event -> scheduleUpdateGUI("EventPreferenceChange"),
|
|
||||||
FabricPrivacy::logException
|
|
||||||
));
|
|
||||||
disposable.add(RxBus.INSTANCE
|
|
||||||
.toObservable(EventPumpStatusChanged.class)
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe(event -> updatePumpStatus(event.getStatus()),
|
|
||||||
FabricPrivacy::logException
|
|
||||||
));
|
|
||||||
disposable.add(RxBus.INSTANCE
|
|
||||||
.toObservable(EventIobCalculationProgress.class)
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe(event -> {
|
|
||||||
if (iobCalculationProgressView != null)
|
|
||||||
iobCalculationProgressView.setText(event.getProgress());
|
|
||||||
},
|
|
||||||
FabricPrivacy::logException
|
|
||||||
));
|
|
||||||
sRefreshLoop = () -> {
|
|
||||||
scheduleUpdateGUI("refreshLoop");
|
|
||||||
sLoopHandler.postDelayed(sRefreshLoop, 60 * 1000L);
|
|
||||||
};
|
|
||||||
sLoopHandler.postDelayed(sRefreshLoop, 60 * 1000L);
|
|
||||||
registerForContextMenu(apsModeView);
|
|
||||||
registerForContextMenu(activeProfileView);
|
|
||||||
registerForContextMenu(tempTargetView);
|
|
||||||
updateGUI("onResume");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(final EventNewOpenLoopNotification ev) {
|
|
||||||
scheduleUpdateGUI("EventNewOpenLoopNotification");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void hideTempRecommendation() {
|
private void hideTempRecommendation() {
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
if (activity != null)
|
if (activity != null)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.general.smsCommunicator;
|
package info.nightscout.androidaps.plugins.general.smsCommunicator;
|
||||||
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -9,17 +8,21 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.plugins.common.SubscriberFragment;
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import info.nightscout.androidaps.plugins.general.smsCommunicator.events.EventSmsCommunicatorUpdateGui;
|
import info.nightscout.androidaps.plugins.general.smsCommunicator.events.EventSmsCommunicatorUpdateGui;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
|
||||||
public class SmsCommunicatorFragment extends SubscriberFragment {
|
public class SmsCommunicatorFragment extends Fragment {
|
||||||
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
TextView logView;
|
TextView logView;
|
||||||
|
|
||||||
public SmsCommunicatorFragment() {
|
public SmsCommunicatorFragment() {
|
||||||
|
@ -36,38 +39,45 @@ public class SmsCommunicatorFragment extends SubscriberFragment {
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Override
|
||||||
public void onStatusEvent(final EventSmsCommunicatorUpdateGui ev) {
|
public synchronized void onResume() {
|
||||||
updateGUI();
|
super.onResume();
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventSmsCommunicatorUpdateGui.class)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(event -> updateGui(), FabricPrivacy::logException)
|
||||||
|
);
|
||||||
|
updateGui();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateGUI() {
|
public synchronized void onPause() {
|
||||||
Activity activity = getActivity();
|
super.onPause();
|
||||||
if (activity != null)
|
disposable.clear();
|
||||||
activity.runOnUiThread(() -> {
|
}
|
||||||
class CustomComparator implements Comparator<Sms> {
|
|
||||||
public int compare(Sms object1, Sms object2) {
|
|
||||||
return (int) (object1.date - object2.date);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Collections.sort(SmsCommunicatorPlugin.getPlugin().messages, new CustomComparator());
|
|
||||||
int messagesToShow = 40;
|
|
||||||
|
|
||||||
int start = Math.max(0, SmsCommunicatorPlugin.getPlugin().messages.size() - messagesToShow);
|
protected void updateGui() {
|
||||||
|
class CustomComparator implements Comparator<Sms> {
|
||||||
|
public int compare(Sms object1, Sms object2) {
|
||||||
|
return (int) (object1.date - object2.date);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Collections.sort(SmsCommunicatorPlugin.getPlugin().messages, new CustomComparator());
|
||||||
|
int messagesToShow = 40;
|
||||||
|
|
||||||
String logText = "";
|
int start = Math.max(0, SmsCommunicatorPlugin.getPlugin().messages.size() - messagesToShow);
|
||||||
for (int x = start; x < SmsCommunicatorPlugin.getPlugin().messages.size(); x++) {
|
|
||||||
Sms sms = SmsCommunicatorPlugin.getPlugin().messages.get(x);
|
String logText = "";
|
||||||
if (sms.ignored) {
|
for (int x = start; x < SmsCommunicatorPlugin.getPlugin().messages.size(); x++) {
|
||||||
logText += DateUtil.timeString(sms.date) + " <<< " + "░ " + sms.phoneNumber + " <b>" + sms.text + "</b><br>";
|
Sms sms = SmsCommunicatorPlugin.getPlugin().messages.get(x);
|
||||||
} else if (sms.received) {
|
if (sms.ignored) {
|
||||||
logText += DateUtil.timeString(sms.date) + " <<< " + (sms.processed ? "● " : "○ ") + sms.phoneNumber + " <b>" + sms.text + "</b><br>";
|
logText += DateUtil.timeString(sms.date) + " <<< " + "░ " + sms.phoneNumber + " <b>" + sms.text + "</b><br>";
|
||||||
} else if (sms.sent) {
|
} else if (sms.received) {
|
||||||
logText += DateUtil.timeString(sms.date) + " >>> " + (sms.processed ? "● " : "○ ") + sms.phoneNumber + " <b>" + sms.text + "</b><br>";
|
logText += DateUtil.timeString(sms.date) + " <<< " + (sms.processed ? "● " : "○ ") + sms.phoneNumber + " <b>" + sms.text + "</b><br>";
|
||||||
}
|
} else if (sms.sent) {
|
||||||
}
|
logText += DateUtil.timeString(sms.date) + " >>> " + (sms.processed ? "● " : "○ ") + sms.phoneNumber + " <b>" + sms.text + "</b><br>";
|
||||||
logView.setText(Html.fromHtml(logText));
|
}
|
||||||
});
|
}
|
||||||
|
logView.setText(Html.fromHtml(logText));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ import android.os.Bundle;
|
||||||
import android.telephony.SmsManager;
|
import android.telephony.SmsManager;
|
||||||
import android.telephony.SmsMessage;
|
import android.telephony.SmsMessage;
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -25,7 +23,6 @@ import info.nightscout.androidaps.data.ProfileStore;
|
||||||
import info.nightscout.androidaps.db.BgReading;
|
import info.nightscout.androidaps.db.BgReading;
|
||||||
import info.nightscout.androidaps.db.DatabaseHelper;
|
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||||
import info.nightscout.androidaps.db.Source;
|
import info.nightscout.androidaps.db.Source;
|
||||||
import info.nightscout.androidaps.events.EventAppExit;
|
|
||||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||||
import info.nightscout.androidaps.events.EventRefreshOverview;
|
import info.nightscout.androidaps.events.EventRefreshOverview;
|
||||||
import info.nightscout.androidaps.interfaces.Constraint;
|
import info.nightscout.androidaps.interfaces.Constraint;
|
||||||
|
@ -176,7 +173,7 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
||||||
log.debug("Ignoring SMS from: " + receivedSms.phoneNumber + ". Sender not allowed");
|
log.debug("Ignoring SMS from: " + receivedSms.phoneNumber + ". Sender not allowed");
|
||||||
receivedSms.ignored = true;
|
receivedSms.ignored = true;
|
||||||
messages.add(receivedSms);
|
messages.add(receivedSms);
|
||||||
MainApp.bus().post(new EventSmsCommunicatorUpdateGui());
|
RxBus.INSTANCE.send(new EventSmsCommunicatorUpdateGui());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,7 +265,7 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MainApp.bus().post(new EventSmsCommunicatorUpdateGui());
|
RxBus.INSTANCE.send(new EventSmsCommunicatorUpdateGui());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
@ -794,7 +791,7 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
||||||
RxBus.INSTANCE.send(new EventNewNotification(notification));
|
RxBus.INSTANCE.send(new EventNewNotification(notification));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
MainApp.bus().post(new EventSmsCommunicatorUpdateGui());
|
RxBus.INSTANCE.send(new EventSmsCommunicatorUpdateGui());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.general.smsCommunicator.events;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.events.EventUpdateGui;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 05.08.2016.
|
|
||||||
*/
|
|
||||||
public class EventSmsCommunicatorUpdateGui extends EventUpdateGui {
|
|
||||||
}
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
package info.nightscout.androidaps.plugins.general.smsCommunicator.events
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.events.EventUpdateGui
|
||||||
|
|
||||||
|
class EventSmsCommunicatorUpdateGui : EventUpdateGui()
|
|
@ -12,7 +12,6 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Config;
|
import info.nightscout.androidaps.Config;
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.ProfileStore;
|
import info.nightscout.androidaps.data.ProfileStore;
|
||||||
import info.nightscout.androidaps.events.EventProfileStoreChanged;
|
import info.nightscout.androidaps.events.EventProfileStoreChanged;
|
||||||
|
@ -58,13 +57,11 @@ public class NSProfilePlugin extends PluginBase implements ProfileInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
MainApp.bus().register(this);
|
|
||||||
super.onStart();
|
super.onStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop() {
|
protected void onStop() {
|
||||||
MainApp.bus().unregister(this);
|
|
||||||
super.onStop();
|
super.onStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,6 @@ import android.content.Intent;
|
||||||
import android.content.ServiceConnection;
|
import android.content.ServiceConnection;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||||
|
|
|
@ -5,8 +5,6 @@ import android.content.IntentFilter;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
@ -69,7 +67,6 @@ import info.nightscout.androidaps.queue.commands.Command;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,6 @@ import android.content.IntentFilter;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
|
@ -99,12 +99,6 @@ public class DanaRSService extends Service {
|
||||||
private long lastApproachingDailyLimit = 0;
|
private long lastApproachingDailyLimit = 0;
|
||||||
|
|
||||||
public DanaRSService() {
|
public DanaRSService() {
|
||||||
try {
|
|
||||||
MainApp.bus().unregister(this);
|
|
||||||
} catch (RuntimeException x) {
|
|
||||||
// Ignore
|
|
||||||
}
|
|
||||||
MainApp.bus().register(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.insight;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.events.EventUpdateGui;
|
|
||||||
|
|
||||||
public class EventLocalInsightUpdateGUI extends EventUpdateGui {
|
|
||||||
}
|
|
|
@ -3,8 +3,6 @@ package info.nightscout.androidaps.plugins.pump.insight;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -12,14 +10,16 @@ import android.widget.Button;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
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.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.pump.insight.app_layer.parameter_blocks.TBROverNotificationBlock;
|
import info.nightscout.androidaps.plugins.pump.insight.app_layer.parameter_blocks.TBROverNotificationBlock;
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.descriptors.ActiveBasalRate;
|
import info.nightscout.androidaps.plugins.pump.insight.descriptors.ActiveBasalRate;
|
||||||
|
@ -28,11 +28,16 @@ import info.nightscout.androidaps.plugins.pump.insight.descriptors.ActiveTBR;
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.descriptors.CartridgeStatus;
|
import info.nightscout.androidaps.plugins.pump.insight.descriptors.CartridgeStatus;
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.descriptors.InsightState;
|
import info.nightscout.androidaps.plugins.pump.insight.descriptors.InsightState;
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.descriptors.TotalDailyDose;
|
import info.nightscout.androidaps.plugins.pump.insight.descriptors.TotalDailyDose;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.insight.events.EventLocalInsightUpdateGUI;
|
||||||
import info.nightscout.androidaps.queue.Callback;
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
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 io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
|
||||||
public class LocalInsightFragment extends SubscriberFragment implements View.OnClickListener {
|
public class LocalInsightFragment extends Fragment implements View.OnClickListener {
|
||||||
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
private static final boolean ENABLE_OPERATING_MODE_BUTTON = false;
|
private static final boolean ENABLE_OPERATING_MODE_BUTTON = false;
|
||||||
|
|
||||||
|
@ -61,6 +66,23 @@ public class LocalInsightFragment extends SubscriberFragment implements View.OnC
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventLocalInsightUpdateGUI.class)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(event -> updateGUI(), FabricPrivacy::logException)
|
||||||
|
);
|
||||||
|
updateGUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
disposable.clear();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void onDestroyView() {
|
public synchronized void onDestroyView() {
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
|
@ -121,12 +143,6 @@ public class LocalInsightFragment extends SubscriberFragment implements View.OnC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onUpdateGUIEvent(EventLocalInsightUpdateGUI event) {
|
|
||||||
updateGUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void updateGUI() {
|
protected void updateGUI() {
|
||||||
if (!viewsCreated) return;
|
if (!viewsCreated) return;
|
||||||
statusItemContainer.removeAllViews();
|
statusItemContainer.removeAllViews();
|
||||||
|
|
|
@ -118,6 +118,7 @@ import info.nightscout.androidaps.plugins.pump.insight.descriptors.InsightState;
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.descriptors.OperatingMode;
|
import info.nightscout.androidaps.plugins.pump.insight.descriptors.OperatingMode;
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.descriptors.PumpTime;
|
import info.nightscout.androidaps.plugins.pump.insight.descriptors.PumpTime;
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.descriptors.TotalDailyDose;
|
import info.nightscout.androidaps.plugins.pump.insight.descriptors.TotalDailyDose;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.insight.events.EventLocalInsightUpdateGUI;
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.exceptions.InsightException;
|
import info.nightscout.androidaps.plugins.pump.insight.exceptions.InsightException;
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.exceptions.app_layer_errors.AppLayerErrorException;
|
import info.nightscout.androidaps.plugins.pump.insight.exceptions.app_layer_errors.AppLayerErrorException;
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.exceptions.app_layer_errors.NoActiveTBRToCanceLException;
|
import info.nightscout.androidaps.plugins.pump.insight.exceptions.app_layer_errors.NoActiveTBRToCanceLException;
|
||||||
|
@ -424,7 +425,7 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
}
|
}
|
||||||
lastUpdated = System.currentTimeMillis();
|
lastUpdated = System.currentTimeMillis();
|
||||||
new Handler(Looper.getMainLooper()).post(() -> {
|
new Handler(Looper.getMainLooper()).post(() -> {
|
||||||
MainApp.bus().post(new EventLocalInsightUpdateGUI());
|
RxBus.INSTANCE.send(new EventLocalInsightUpdateGUI());
|
||||||
RxBus.INSTANCE.send(new EventRefreshOverview("LocalInsightPlugin::fetchStatus"));
|
RxBus.INSTANCE.send(new EventRefreshOverview("LocalInsightPlugin::fetchStatus"));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1602,7 +1603,7 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
tbrOverNotificationBlock = null;
|
tbrOverNotificationBlock = null;
|
||||||
new Handler(Looper.getMainLooper()).post(() -> RxBus.INSTANCE.send(new EventRefreshOverview("LocalInsightPlugin::onStateChanged")));
|
new Handler(Looper.getMainLooper()).post(() -> RxBus.INSTANCE.send(new EventRefreshOverview("LocalInsightPlugin::onStateChanged")));
|
||||||
}
|
}
|
||||||
new Handler(Looper.getMainLooper()).post(() -> MainApp.bus().post(new EventLocalInsightUpdateGUI()));
|
new Handler(Looper.getMainLooper()).post(() -> RxBus.INSTANCE.send(new EventLocalInsightUpdateGUI()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.insight.events
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.events.EventUpdateGui
|
||||||
|
|
||||||
|
class EventLocalInsightUpdateGUI : EventUpdateGui()
|
|
@ -19,7 +19,6 @@ import org.slf4j.LoggerFactory;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.activities.NoSplashActivity;
|
import info.nightscout.androidaps.activities.NoSplashActivity;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
|
@ -82,7 +81,6 @@ public class MedtronicHistoryActivity extends NoSplashActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
MainApp.bus().register(this);
|
|
||||||
filterHistory(selectedGroup);
|
filterHistory(selectedGroup);
|
||||||
setHistoryTypeSpinner();
|
setHistoryTypeSpinner();
|
||||||
}
|
}
|
||||||
|
@ -106,7 +104,6 @@ public class MedtronicHistoryActivity extends NoSplashActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
MainApp.bus().unregister(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,6 @@ import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.db.DatabaseHelper;
|
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||||
import info.nightscout.androidaps.db.ICallback;
|
import info.nightscout.androidaps.db.ICallback;
|
||||||
import info.nightscout.androidaps.db.Source;
|
import info.nightscout.androidaps.db.Source;
|
||||||
|
@ -185,7 +184,6 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (L.isEnabled(L.DATATREATMENTS))
|
if (L.isEnabled(L.DATATREATMENTS))
|
||||||
log.debug("Firing EventReloadTreatmentData");
|
log.debug("Firing EventReloadTreatmentData");
|
||||||
MainApp.bus().post(event);
|
|
||||||
RxBus.INSTANCE.send(event);
|
RxBus.INSTANCE.send(event);
|
||||||
if (DatabaseHelper.earliestDataChange != null) {
|
if (DatabaseHelper.earliestDataChange != null) {
|
||||||
if (L.isEnabled(L.DATATREATMENTS))
|
if (L.isEnabled(L.DATATREATMENTS))
|
||||||
|
|
|
@ -102,7 +102,6 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
MainApp.bus().register(this);
|
|
||||||
initializeTempBasalData();
|
initializeTempBasalData();
|
||||||
initializeTreatmentData();
|
initializeTreatmentData();
|
||||||
initializeExtendedBolusData();
|
initializeExtendedBolusData();
|
||||||
|
@ -149,7 +148,6 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop() {
|
protected void onStop() {
|
||||||
MainApp.bus().register(this);
|
|
||||||
disposable.clear();
|
disposable.clear();
|
||||||
super.onStop();
|
super.onStop();
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -19,8 +18,6 @@ import androidx.fragment.app.FragmentManager;
|
||||||
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;
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -17,8 +16,6 @@ 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 info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.Intervals;
|
import info.nightscout.androidaps.data.Intervals;
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -19,8 +18,6 @@ import androidx.fragment.app.FragmentManager;
|
||||||
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 org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -34,7 +31,6 @@ import info.nightscout.androidaps.db.Source;
|
||||||
import info.nightscout.androidaps.events.EventProfileNeedsUpdate;
|
import info.nightscout.androidaps.events.EventProfileNeedsUpdate;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import info.nightscout.androidaps.plugins.common.SubscriberFragment;
|
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||||
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;
|
||||||
|
|
|
@ -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.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
@ -17,8 +16,6 @@ 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 info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.Intervals;
|
import info.nightscout.androidaps.data.Intervals;
|
||||||
|
|
|
@ -5,8 +5,8 @@ import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.BatteryManager;
|
import android.os.BatteryManager;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.events.EventChargingState;
|
import info.nightscout.androidaps.events.EventChargingState;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
|
|
||||||
public class ChargingStateReceiver extends BroadcastReceiver {
|
public class ChargingStateReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ public class ChargingStateReceiver extends BroadcastReceiver {
|
||||||
EventChargingState event = grabChargingState(context);
|
EventChargingState event = grabChargingState(context);
|
||||||
|
|
||||||
if (event != null)
|
if (event != null)
|
||||||
MainApp.bus().post(event);
|
RxBus.INSTANCE.send(event);
|
||||||
lastEvent = event;
|
lastEvent = event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,6 @@ public class DataService extends IntentService {
|
||||||
|
|
||||||
public DataService() {
|
public DataService() {
|
||||||
super("DataService");
|
super("DataService");
|
||||||
registerBus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -115,16 +114,6 @@ public class DataService extends IntentService {
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
MainApp.bus().unregister(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void registerBus() {
|
|
||||||
try {
|
|
||||||
MainApp.bus().unregister(this);
|
|
||||||
} catch (RuntimeException x) {
|
|
||||||
// Ignore
|
|
||||||
}
|
|
||||||
MainApp.bus().register(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleNewDataFromNSClient(Intent intent) {
|
private void handleNewDataFromNSClient(Intent intent) {
|
||||||
|
|
|
@ -5,8 +5,6 @@ import android.content.Intent;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -46,7 +44,6 @@ import info.nightscout.androidaps.setupwizard.elements.SWHtmlLink;
|
||||||
import info.nightscout.androidaps.setupwizard.elements.SWInfotext;
|
import info.nightscout.androidaps.setupwizard.elements.SWInfotext;
|
||||||
import info.nightscout.androidaps.setupwizard.elements.SWPlugin;
|
import info.nightscout.androidaps.setupwizard.elements.SWPlugin;
|
||||||
import info.nightscout.androidaps.setupwizard.elements.SWRadioButton;
|
import info.nightscout.androidaps.setupwizard.elements.SWRadioButton;
|
||||||
import info.nightscout.androidaps.setupwizard.events.EventSWLabel;
|
|
||||||
import info.nightscout.androidaps.setupwizard.events.EventSWUpdate;
|
import info.nightscout.androidaps.setupwizard.events.EventSWUpdate;
|
||||||
import info.nightscout.androidaps.utils.AndroidPermission;
|
import info.nightscout.androidaps.utils.AndroidPermission;
|
||||||
import info.nightscout.androidaps.utils.LocaleHelper;
|
import info.nightscout.androidaps.utils.LocaleHelper;
|
||||||
|
@ -109,7 +106,7 @@ public class SWDefinition {
|
||||||
.visibility(() -> !SP.getBoolean(R.string.key_i_understand, false))
|
.visibility(() -> !SP.getBoolean(R.string.key_i_understand, false))
|
||||||
.action(() -> {
|
.action(() -> {
|
||||||
SP.putBoolean(R.string.key_i_understand, true);
|
SP.putBoolean(R.string.key_i_understand, true);
|
||||||
MainApp.bus().post(new EventSWUpdate(false));
|
RxBus.INSTANCE.send(new EventSWUpdate(false));
|
||||||
}))
|
}))
|
||||||
.visibility(() -> !SP.getBoolean(R.string.key_i_understand, false))
|
.visibility(() -> !SP.getBoolean(R.string.key_i_understand, false))
|
||||||
.validator(() -> SP.getBoolean(R.string.key_i_understand, false));
|
.validator(() -> SP.getBoolean(R.string.key_i_understand, false));
|
||||||
|
@ -172,7 +169,7 @@ public class SWDefinition {
|
||||||
ConfigBuilderPlugin.getPlugin().processOnEnabledCategoryChanged(NSClientPlugin.getPlugin(), PluginType.GENERAL);
|
ConfigBuilderPlugin.getPlugin().processOnEnabledCategoryChanged(NSClientPlugin.getPlugin(), PluginType.GENERAL);
|
||||||
ConfigBuilderPlugin.getPlugin().storeSettings("SetupWizard");
|
ConfigBuilderPlugin.getPlugin().storeSettings("SetupWizard");
|
||||||
RxBus.INSTANCE.send(new EventConfigBuilderChange());
|
RxBus.INSTANCE.send(new EventConfigBuilderChange());
|
||||||
MainApp.bus().post(new EventSWUpdate(true));
|
RxBus.INSTANCE.send(new EventSWUpdate(true));
|
||||||
})
|
})
|
||||||
.visibility(() -> !NSClientPlugin.getPlugin().isEnabled(PluginType.GENERAL)))
|
.visibility(() -> !NSClientPlugin.getPlugin().isEnabled(PluginType.GENERAL)))
|
||||||
.add(new SWEditUrl()
|
.add(new SWEditUrl()
|
||||||
|
@ -374,7 +371,7 @@ public class SWDefinition {
|
||||||
ConfigBuilderPlugin.getPlugin().processOnEnabledCategoryChanged(LoopPlugin.getPlugin(), PluginType.LOOP);
|
ConfigBuilderPlugin.getPlugin().processOnEnabledCategoryChanged(LoopPlugin.getPlugin(), PluginType.LOOP);
|
||||||
ConfigBuilderPlugin.getPlugin().storeSettings("SetupWizard");
|
ConfigBuilderPlugin.getPlugin().storeSettings("SetupWizard");
|
||||||
RxBus.INSTANCE.send(new EventConfigBuilderChange());
|
RxBus.INSTANCE.send(new EventConfigBuilderChange());
|
||||||
MainApp.bus().post(new EventSWUpdate(true));
|
RxBus.INSTANCE.send(new EventSWUpdate(true));
|
||||||
})
|
})
|
||||||
.visibility(() -> !LoopPlugin.getPlugin().isEnabled(PluginType.LOOP)))
|
.visibility(() -> !LoopPlugin.getPlugin().isEnabled(PluginType.LOOP)))
|
||||||
.validator(() -> LoopPlugin.getPlugin().isEnabled(PluginType.LOOP))
|
.validator(() -> LoopPlugin.getPlugin().isEnabled(PluginType.LOOP))
|
||||||
|
|
|
@ -12,8 +12,6 @@ import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -76,7 +74,8 @@ public class SetupWizardActivity extends NoSplashAppCompatActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
if (currentWizardPage == 0) OKDialog.showConfirmation(this, MainApp.gs(R.string.exitwizard), this::finish);
|
if (currentWizardPage == 0)
|
||||||
|
OKDialog.showConfirmation(this, MainApp.gs(R.string.exitwizard), this::finish);
|
||||||
else showPreviousPage(null);
|
else showPreviousPage(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,14 +87,12 @@ public class SetupWizardActivity extends NoSplashAppCompatActivity {
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
MainApp.bus().unregister(this);
|
|
||||||
disposable.clear();
|
disposable.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
MainApp.bus().register(this);
|
|
||||||
swDefinition.setActivity(this);
|
swDefinition.setActivity(this);
|
||||||
disposable.add(RxBus.INSTANCE
|
disposable.add(RxBus.INSTANCE
|
||||||
.toObservable(EventPumpStatusChanged.class)
|
.toObservable(EventPumpStatusChanged.class)
|
||||||
|
@ -117,13 +114,14 @@ public class SetupWizardActivity extends NoSplashAppCompatActivity {
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(event -> updateButtons(), FabricPrivacy::logException)
|
.subscribe(event -> updateButtons(), FabricPrivacy::logException)
|
||||||
);
|
);
|
||||||
}
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventSWUpdate.class)
|
||||||
@Subscribe
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
public void onContentUpdate(EventSWUpdate ev) {
|
.subscribe(event -> {
|
||||||
if (ev.redraw)
|
if (event.getRedraw()) generateLayout();
|
||||||
generateLayout();
|
updateButtons();
|
||||||
updateButtons();
|
}, FabricPrivacy::logException)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateLayout() {
|
private void generateLayout() {
|
||||||
|
@ -133,7 +131,7 @@ public class SetupWizardActivity extends NoSplashAppCompatActivity {
|
||||||
SWItem currentItem = currentScreen.items.get(i);
|
SWItem currentItem = currentScreen.items.get(i);
|
||||||
currentItem.generateDialog(layout);
|
currentItem.generateDialog(layout);
|
||||||
}
|
}
|
||||||
scrollView.smoothScrollTo(0,0);
|
scrollView.smoothScrollTo(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateButtons() {
|
private void updateButtons() {
|
||||||
|
|
|
@ -16,6 +16,7 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import info.nightscout.androidaps.setupwizard.events.EventSWLabel;
|
import info.nightscout.androidaps.setupwizard.events.EventSWLabel;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
|
||||||
|
@ -62,7 +63,7 @@ public class SWEditUrl extends SWItem {
|
||||||
if (Patterns.WEB_URL.matcher(s).matches())
|
if (Patterns.WEB_URL.matcher(s).matches())
|
||||||
save(s.toString(), updateDelay);
|
save(s.toString(), updateDelay);
|
||||||
else
|
else
|
||||||
MainApp.bus().post(new EventSWLabel(MainApp.gs(R.string.error_url_not_valid)));
|
RxBus.INSTANCE.send(new EventSWLabel(MainApp.gs(R.string.error_url_not_valid)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -12,9 +12,9 @@ import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
|
||||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import info.nightscout.androidaps.setupwizard.events.EventSWUpdate;
|
import info.nightscout.androidaps.setupwizard.events.EventSWUpdate;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ public class SWItem {
|
||||||
if (L.isEnabled(L.CORE))
|
if (L.isEnabled(L.CORE))
|
||||||
log.debug("Firing EventPreferenceChange");
|
log.debug("Firing EventPreferenceChange");
|
||||||
RxBus.INSTANCE.send(new EventPreferenceChange(preferenceId));
|
RxBus.INSTANCE.send(new EventPreferenceChange(preferenceId));
|
||||||
MainApp.bus().post(new EventSWUpdate());
|
RxBus.INSTANCE.send(new EventSWUpdate(false));
|
||||||
scheduledEventPost = null;
|
scheduledEventPost = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,7 @@ public class SWPlugin extends SWItem {
|
||||||
ConfigBuilderPlugin.getPlugin().processOnEnabledCategoryChanged(plugin, pType);
|
ConfigBuilderPlugin.getPlugin().processOnEnabledCategoryChanged(plugin, pType);
|
||||||
ConfigBuilderPlugin.getPlugin().storeSettings("SetupWizard");
|
ConfigBuilderPlugin.getPlugin().storeSettings("SetupWizard");
|
||||||
RxBus.INSTANCE.send(new EventConfigBuilderChange());
|
RxBus.INSTANCE.send(new EventConfigBuilderChange());
|
||||||
MainApp.bus().post(new EventSWUpdate());
|
RxBus.INSTANCE.send(new EventSWUpdate(false));
|
||||||
});
|
});
|
||||||
layout.addView(radioGroup);
|
layout.addView(radioGroup);
|
||||||
super.generateDialog(layout);
|
super.generateDialog(layout);
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
package info.nightscout.androidaps.setupwizard.events;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.events.Event;
|
|
||||||
|
|
||||||
public class EventSWUpdate extends Event {
|
|
||||||
public boolean redraw = false;
|
|
||||||
|
|
||||||
public EventSWUpdate() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public EventSWUpdate(boolean redraw) {
|
|
||||||
this.redraw = redraw;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
package info.nightscout.androidaps.setupwizard.events
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.events.Event
|
||||||
|
|
||||||
|
class EventSWUpdate(var redraw: Boolean) : Event()
|
|
@ -5,8 +5,6 @@ import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
|
||||||
import com.squareup.otto.Bus;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
@ -52,8 +50,6 @@ public class AAPSMocker {
|
||||||
private static ProfileStore profileStore;
|
private static ProfileStore profileStore;
|
||||||
public static final String TESTPROFILENAME = "someProfile";
|
public static final String TESTPROFILENAME = "someProfile";
|
||||||
|
|
||||||
public static Intent intentSent = null;
|
|
||||||
|
|
||||||
public static CommandQueue queue;
|
public static CommandQueue queue;
|
||||||
public static ConfigBuilderPlugin configBuilderPlugin;
|
public static ConfigBuilderPlugin configBuilderPlugin;
|
||||||
public static ProfileFunctions profileFunctions;
|
public static ProfileFunctions profileFunctions;
|
||||||
|
@ -157,6 +153,7 @@ public class AAPSMocker {
|
||||||
when(MainApp.gs(R.string.suspendloop)).thenReturn("Suspend loop");
|
when(MainApp.gs(R.string.suspendloop)).thenReturn("Suspend loop");
|
||||||
when(MainApp.gs(R.string.pumpNotInitialized)).thenReturn("Pump not initialized!");
|
when(MainApp.gs(R.string.pumpNotInitialized)).thenReturn("Pump not initialized!");
|
||||||
when(MainApp.gs(R.string.increasingmaxbasal)).thenReturn("Increasing max basal value because setting is lower than your max basal in profile");
|
when(MainApp.gs(R.string.increasingmaxbasal)).thenReturn("Increasing max basal value because setting is lower than your max basal in profile");
|
||||||
|
when(MainApp.gs(R.string.overview_bolusprogress_delivered)).thenReturn("Delivered");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MainApp mockMainApp() {
|
public static MainApp mockMainApp() {
|
||||||
|
@ -180,11 +177,6 @@ public class AAPSMocker {
|
||||||
return constraintChecker;
|
return constraintChecker;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void mockBus() {
|
|
||||||
Bus bus = PowerMockito.mock(Bus.class);
|
|
||||||
when(MainApp.bus()).thenReturn(bus);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void mockSP() {
|
public static void mockSP() {
|
||||||
PowerMockito.mockStatic(SP.class);
|
PowerMockito.mockStatic(SP.class);
|
||||||
when(SP.getLong(anyInt(), anyLong())).thenReturn(0L);
|
when(SP.getLong(anyInt(), anyLong())).thenReturn(0L);
|
||||||
|
@ -299,30 +291,4 @@ public class AAPSMocker {
|
||||||
return iobCobCalculatorPlugin;
|
return iobCobCalculatorPlugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static MockedBus bus = new MockedBus();
|
|
||||||
|
|
||||||
public static void prepareMockedBus() {
|
|
||||||
when(MainApp.bus()).thenReturn(bus);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class MockedBus extends Bus {
|
|
||||||
public boolean registered = false;
|
|
||||||
public boolean notificationSent = false;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void register(Object event) {
|
|
||||||
registered = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void unregister(Object event) {
|
|
||||||
registered = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void post(Object event) {
|
|
||||||
notificationSent = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,13 +20,9 @@ import info.nightscout.androidaps.plugins.general.overview.OverviewPlugin;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
public class MainAppTest {
|
public class MainAppTest {
|
||||||
|
/*
|
||||||
MainApp mainApp = new MainApp();
|
MainApp mainApp = new MainApp();
|
||||||
|
|
||||||
@Test
|
|
||||||
public void busTest() {
|
|
||||||
Assert.assertNotNull(mainApp.bus());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void gsTest() {
|
public void gsTest() {
|
||||||
Assert.assertNotNull(mainApp.gs(R.string.app_name));
|
Assert.assertNotNull(mainApp.gs(R.string.app_name));
|
||||||
|
@ -125,5 +121,5 @@ public class MainAppTest {
|
||||||
// logger not initialized in Roboelectric
|
// logger not initialized in Roboelectric
|
||||||
Assert.assertNull(LoggerUtils.getLogDirectory());
|
Assert.assertNull(LoggerUtils.getLogDirectory());
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package info.nightscout.androidaps.data;
|
package info.nightscout.androidaps.data;
|
||||||
|
|
||||||
import com.squareup.otto.Bus;
|
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -26,7 +24,7 @@ import info.nightscout.androidaps.utils.T;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({MainApp.class, Bus.class, ConfigBuilderPlugin.class, TreatmentsPlugin.class, TreatmentService.class})
|
@PrepareForTest({MainApp.class, ConfigBuilderPlugin.class, TreatmentsPlugin.class, TreatmentService.class})
|
||||||
public class ProfileIntervalsTest {
|
public class ProfileIntervalsTest {
|
||||||
private final long startDate = DateUtil.now();
|
private final long startDate = DateUtil.now();
|
||||||
ProfileIntervals<ProfileSwitch> list = new ProfileIntervals<>();
|
ProfileIntervals<ProfileSwitch> list = new ProfileIntervals<>();
|
||||||
|
@ -91,7 +89,6 @@ public class ProfileIntervalsTest {
|
||||||
public void prepareMock() {
|
public void prepareMock() {
|
||||||
AAPSMocker.mockMainApp();
|
AAPSMocker.mockMainApp();
|
||||||
AAPSMocker.mockStrings();
|
AAPSMocker.mockStrings();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
AAPSMocker.mockConfigBuilder();
|
AAPSMocker.mockConfigBuilder();
|
||||||
AAPSMocker.mockTreatmentPlugin();
|
AAPSMocker.mockTreatmentPlugin();
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin;
|
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin;
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
|
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -134,7 +133,7 @@ public class ProfileTest {
|
||||||
|
|
||||||
// Test hour alignment
|
// Test hour alignment
|
||||||
ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().is30minBasalRatesCapable = false;
|
ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().is30minBasalRatesCapable = false;
|
||||||
((AAPSMocker.MockedBus) MainApp.bus()).notificationSent = false;
|
//((AAPSMocker.MockedBus) MainApp.bus()).notificationSent = false;
|
||||||
p = new Profile(new JSONObject(notAllignedBasalValidProfile), 100, 0);
|
p = new Profile(new JSONObject(notAllignedBasalValidProfile), 100, 0);
|
||||||
p.isValid("Test");
|
p.isValid("Test");
|
||||||
//Assert.assertEquals(true, ((AAPSMocker.MockedBus) MainApp.bus()).notificationSent);
|
//Assert.assertEquals(true, ((AAPSMocker.MockedBus) MainApp.bus()).notificationSent);
|
||||||
|
@ -145,7 +144,6 @@ public class ProfileTest {
|
||||||
AAPSMocker.mockMainApp();
|
AAPSMocker.mockMainApp();
|
||||||
AAPSMocker.mockConfigBuilder();
|
AAPSMocker.mockConfigBuilder();
|
||||||
AAPSMocker.mockStrings();
|
AAPSMocker.mockStrings();
|
||||||
AAPSMocker.prepareMockedBus();
|
|
||||||
|
|
||||||
when(ConfigBuilderPlugin.getPlugin().getActivePump()).thenReturn(pump);
|
when(ConfigBuilderPlugin.getPlugin().getActivePump()).thenReturn(pump);
|
||||||
|
|
||||||
|
|
|
@ -2,11 +2,8 @@ package info.nightscout.androidaps.interfaces;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import com.squareup.otto.Bus;
|
|
||||||
|
|
||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
|
|
||||||
import org.json.JSONException;
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
@ -20,12 +17,12 @@ import info.AAPSMocker;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.ConstraintChecker;
|
import info.nightscout.androidaps.data.ConstraintChecker;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
|
||||||
import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesPlugin;
|
|
||||||
import info.nightscout.androidaps.plugins.constraints.safety.SafetyPlugin;
|
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin;
|
import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin;
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSMA.OpenAPSMAPlugin;
|
import info.nightscout.androidaps.plugins.aps.openAPSMA.OpenAPSMAPlugin;
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin;
|
import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.constraints.safety.SafetyPlugin;
|
||||||
import info.nightscout.androidaps.plugins.pump.combo.ComboPlugin;
|
import info.nightscout.androidaps.plugins.pump.combo.ComboPlugin;
|
||||||
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;
|
||||||
|
@ -73,7 +70,7 @@ public class ConstraintsCheckerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isClosedLoopAllowedTest() {
|
public void isClosedLoopAllowedTest() {
|
||||||
when(SP.getString(R.string.key_aps_mode, "open")).thenReturn("closed");
|
when(SP.getString(R.string.key_aps_mode, "open")).thenReturn("closed");
|
||||||
objectivesPlugin.getObjectives().get(ObjectivesPlugin.INSTANCE.getMAXIOB_ZERO_CL_OBJECTIVE()).setStartedOn(0);
|
objectivesPlugin.getObjectives().get(ObjectivesPlugin.INSTANCE.getMAXIOB_ZERO_CL_OBJECTIVE()).setStartedOn(0);
|
||||||
|
|
||||||
|
@ -247,7 +244,7 @@ public class ConstraintsCheckerTest {
|
||||||
// Apply all limits
|
// Apply all limits
|
||||||
Constraint<Double> d = constraintChecker.getMaxIOBAllowed();
|
Constraint<Double> d = constraintChecker.getMaxIOBAllowed();
|
||||||
Assert.assertEquals(1.5d, d.value());
|
Assert.assertEquals(1.5d, d.value());
|
||||||
Assert.assertEquals(d.getReasonList().toString(),2, d.getReasonList().size());
|
Assert.assertEquals(d.getReasonList().toString(), 2, d.getReasonList().size());
|
||||||
Assert.assertEquals("Safety: Limiting IOB to 1.5 U because of max value in preferences", d.getMostLimitedReasons());
|
Assert.assertEquals("Safety: Limiting IOB to 1.5 U because of max value in preferences", d.getMostLimitedReasons());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -278,7 +275,6 @@ public class ConstraintsCheckerTest {
|
||||||
AAPSMocker.mockConfigBuilder();
|
AAPSMocker.mockConfigBuilder();
|
||||||
AAPSMocker.mockConstraintsChecker();
|
AAPSMocker.mockConstraintsChecker();
|
||||||
AAPSMocker.mockApplicationContext();
|
AAPSMocker.mockApplicationContext();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
AAPSMocker.mockStrings();
|
AAPSMocker.mockStrings();
|
||||||
AAPSMocker.mockSP();
|
AAPSMocker.mockSP();
|
||||||
AAPSMocker.mockCommandQueue();
|
AAPSMocker.mockCommandQueue();
|
||||||
|
@ -311,12 +307,4 @@ public class ConstraintsCheckerTest {
|
||||||
when(mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class)).thenReturn(constraintsPluginsList);
|
when(mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class)).thenReturn(constraintsPluginsList);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class MockedBus extends Bus {
|
|
||||||
@Override
|
|
||||||
public void post(Object event) {
|
|
||||||
notificationSent = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,7 +179,6 @@ public class APSResultTest {
|
||||||
AAPSMocker.mockConfigBuilder();
|
AAPSMocker.mockConfigBuilder();
|
||||||
AAPSMocker.mockSP();
|
AAPSMocker.mockSP();
|
||||||
AAPSMocker.mockStrings();
|
AAPSMocker.mockStrings();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
AAPSMocker.mockProfileFunctions();
|
AAPSMocker.mockProfileFunctions();
|
||||||
AAPSMocker.mockTreatmentService();
|
AAPSMocker.mockTreatmentService();
|
||||||
AAPSMocker.mockL();
|
AAPSMocker.mockL();
|
||||||
|
|
|
@ -2,8 +2,6 @@ package info.nightscout.androidaps.plugins.aps.loop;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import com.squareup.otto.Bus;
|
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -31,7 +29,6 @@ public class LoopPluginTest {
|
||||||
|
|
||||||
VirtualPumpPlugin virtualPumpPlugin;
|
VirtualPumpPlugin virtualPumpPlugin;
|
||||||
LoopPlugin loopPlugin;
|
LoopPlugin loopPlugin;
|
||||||
MockedBus bus;
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPluginInterface() {
|
public void testPluginInterface() {
|
||||||
|
@ -91,17 +88,10 @@ public class LoopPluginTest {
|
||||||
AAPSMocker.mockSP();
|
AAPSMocker.mockSP();
|
||||||
AAPSMocker.mockStrings();
|
AAPSMocker.mockStrings();
|
||||||
|
|
||||||
bus = new MockedBus();
|
|
||||||
when(MainApp.bus()).thenReturn(bus);
|
|
||||||
|
|
||||||
loopPlugin = LoopPlugin.getPlugin();
|
loopPlugin = LoopPlugin.getPlugin();
|
||||||
virtualPumpPlugin = VirtualPumpPlugin.getPlugin();
|
virtualPumpPlugin = VirtualPumpPlugin.getPlugin();
|
||||||
|
|
||||||
when(ConfigBuilderPlugin.getPlugin().getActivePump()).thenReturn(virtualPumpPlugin);
|
when(ConfigBuilderPlugin.getPlugin().getActivePump()).thenReturn(virtualPumpPlugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
class MockedBus extends Bus {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,6 @@ import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
|
||||||
import static org.powermock.api.mockito.PowerMockito.mock;
|
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({MainApp.class, SP.class})
|
@PrepareForTest({MainApp.class, SP.class})
|
||||||
public class ConfigBuilderPluginTest {
|
public class ConfigBuilderPluginTest {
|
||||||
|
@ -29,7 +27,6 @@ public class ConfigBuilderPluginTest {
|
||||||
public void onStartTest() {
|
public void onStartTest() {
|
||||||
ConfigBuilderPlugin configBuilderPlugin = ConfigBuilderPlugin.getPlugin();
|
ConfigBuilderPlugin configBuilderPlugin = ConfigBuilderPlugin.getPlugin();
|
||||||
configBuilderPlugin.setPluginEnabled(PluginType.GENERAL, true);
|
configBuilderPlugin.setPluginEnabled(PluginType.GENERAL, true);
|
||||||
Assert.assertEquals(true, ((AAPSMocker.MockedBus) MainApp.bus()).registered);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -37,7 +34,6 @@ public class ConfigBuilderPluginTest {
|
||||||
ConfigBuilderPlugin configBuilderPlugin = ConfigBuilderPlugin.getPlugin();
|
ConfigBuilderPlugin configBuilderPlugin = ConfigBuilderPlugin.getPlugin();
|
||||||
configBuilderPlugin.setPluginEnabled(PluginType.GENERAL, true);
|
configBuilderPlugin.setPluginEnabled(PluginType.GENERAL, true);
|
||||||
configBuilderPlugin.setPluginEnabled(PluginType.GENERAL, false);
|
configBuilderPlugin.setPluginEnabled(PluginType.GENERAL, false);
|
||||||
Assert.assertEquals(false, ((AAPSMocker.MockedBus) MainApp.bus()).registered);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
|
@ -45,7 +41,6 @@ public class ConfigBuilderPluginTest {
|
||||||
AAPSMocker.mockMainApp();
|
AAPSMocker.mockMainApp();
|
||||||
AAPSMocker.mockApplicationContext();
|
AAPSMocker.mockApplicationContext();
|
||||||
AAPSMocker.mockSP();
|
AAPSMocker.mockSP();
|
||||||
AAPSMocker.prepareMockedBus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,6 @@ import org.junit.runner.RunWith;
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||||
import org.powermock.modules.junit4.PowerMockRunner;
|
import org.powermock.modules.junit4.PowerMockRunner;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import info.AAPSMocker;
|
import info.AAPSMocker;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.interfaces.Constraint;
|
import info.nightscout.androidaps.interfaces.Constraint;
|
||||||
|
@ -82,7 +80,6 @@ public class ObjectivesPluginTest {
|
||||||
public void prepareMock() {
|
public void prepareMock() {
|
||||||
AAPSMocker.mockMainApp();
|
AAPSMocker.mockMainApp();
|
||||||
AAPSMocker.mockConfigBuilder();
|
AAPSMocker.mockConfigBuilder();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
AAPSMocker.mockSP();
|
AAPSMocker.mockSP();
|
||||||
AAPSMocker.mockStrings();
|
AAPSMocker.mockStrings();
|
||||||
|
|
||||||
|
|
|
@ -229,7 +229,6 @@ public class SafetyPluginTest {
|
||||||
AAPSMocker.mockConstraintsChecker();
|
AAPSMocker.mockConstraintsChecker();
|
||||||
AAPSMocker.mockSP();
|
AAPSMocker.mockSP();
|
||||||
AAPSMocker.mockStrings();
|
AAPSMocker.mockStrings();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
|
|
||||||
|
|
||||||
when(ConfigBuilderPlugin.getPlugin().getActivePump()).thenReturn(pump);
|
when(ConfigBuilderPlugin.getPlugin().getActivePump()).thenReturn(pump);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
package info.nightscout.androidaps.plugins.constraints.storage;
|
package info.nightscout.androidaps.plugins.constraints.storage;
|
||||||
|
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.os.StatFs;
|
import android.os.StatFs;
|
||||||
|
|
||||||
|
@ -15,13 +16,12 @@ import java.io.File;
|
||||||
|
|
||||||
import info.AAPSMocker;
|
import info.AAPSMocker;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
|
||||||
import info.nightscout.androidaps.interfaces.Constraint;
|
import info.nightscout.androidaps.interfaces.Constraint;
|
||||||
|
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.powermock.api.mockito.PowerMockito.whenNew;
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
import static org.powermock.api.mockito.PowerMockito.whenNew;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Rumen on 06.03.2019.
|
* Created by Rumen on 06.03.2019.
|
||||||
|
@ -72,7 +72,6 @@ public class StorageConstraintPluginTest extends StorageConstraintPlugin{
|
||||||
public void prepareMock() {
|
public void prepareMock() {
|
||||||
AAPSMocker.mockMainApp();
|
AAPSMocker.mockMainApp();
|
||||||
AAPSMocker.mockStrings();
|
AAPSMocker.mockStrings();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
mockedFile = mock(File.class);
|
mockedFile = mock(File.class);
|
||||||
mockedStatFs = mock(StatFs.class);
|
mockedStatFs = mock(StatFs.class);
|
||||||
storageConstraintPlugin = StorageConstraintPlugin.getPlugin();
|
storageConstraintPlugin = StorageConstraintPlugin.getPlugin();
|
||||||
|
|
|
@ -65,7 +65,6 @@ public class ActionLoopDisableTest {
|
||||||
public void prepareTest() {
|
public void prepareTest() {
|
||||||
AAPSMocker.mockMainApp();
|
AAPSMocker.mockMainApp();
|
||||||
AAPSMocker.mockApplicationContext();
|
AAPSMocker.mockApplicationContext();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
AAPSMocker.mockSP();
|
AAPSMocker.mockSP();
|
||||||
AAPSMocker.mockConfigBuilder();
|
AAPSMocker.mockConfigBuilder();
|
||||||
AAPSMocker.mockCommandQueue();
|
AAPSMocker.mockCommandQueue();
|
||||||
|
|
|
@ -65,7 +65,6 @@ public class ActionLoopEnableTest {
|
||||||
public void prepareTest() {
|
public void prepareTest() {
|
||||||
AAPSMocker.mockMainApp();
|
AAPSMocker.mockMainApp();
|
||||||
AAPSMocker.mockApplicationContext();
|
AAPSMocker.mockApplicationContext();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
AAPSMocker.mockSP();
|
AAPSMocker.mockSP();
|
||||||
AAPSMocker.mockConfigBuilder();
|
AAPSMocker.mockConfigBuilder();
|
||||||
AAPSMocker.mockCommandQueue();
|
AAPSMocker.mockCommandQueue();
|
||||||
|
|
|
@ -63,7 +63,6 @@ public class ActionLoopResumeTest {
|
||||||
AAPSMocker.mockMainApp();
|
AAPSMocker.mockMainApp();
|
||||||
AAPSMocker.mockApplicationContext();
|
AAPSMocker.mockApplicationContext();
|
||||||
AAPSMocker.mockStrings();
|
AAPSMocker.mockStrings();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
AAPSMocker.mockSP();
|
AAPSMocker.mockSP();
|
||||||
AAPSMocker.mockConfigBuilder();
|
AAPSMocker.mockConfigBuilder();
|
||||||
AAPSMocker.mockNSUpload();
|
AAPSMocker.mockNSUpload();
|
||||||
|
|
|
@ -80,7 +80,6 @@ public class ActionLoopSuspendTest {
|
||||||
AAPSMocker.mockMainApp();
|
AAPSMocker.mockMainApp();
|
||||||
AAPSMocker.mockApplicationContext();
|
AAPSMocker.mockApplicationContext();
|
||||||
AAPSMocker.mockStrings();
|
AAPSMocker.mockStrings();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
AAPSMocker.mockSP();
|
AAPSMocker.mockSP();
|
||||||
AAPSMocker.mockConfigBuilder();
|
AAPSMocker.mockConfigBuilder();
|
||||||
AAPSMocker.mockNSUpload();
|
AAPSMocker.mockNSUpload();
|
||||||
|
|
|
@ -6,29 +6,17 @@ import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mockito;
|
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||||
import org.powermock.modules.junit4.PowerMockRunner;
|
import org.powermock.modules.junit4.PowerMockRunner;
|
||||||
|
|
||||||
import info.AAPSMocker;
|
import info.AAPSMocker;
|
||||||
import info.nightscout.androidaps.Constants;
|
|
||||||
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.TempTarget;
|
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.InputBg;
|
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.InputDuration;
|
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.InputString;
|
import info.nightscout.androidaps.plugins.general.automation.elements.InputString;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.OverviewPlugin;
|
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
|
||||||
import info.nightscout.androidaps.queue.Callback;
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
|
||||||
import static org.mockito.ArgumentMatchers.anyString;
|
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({MainApp.class, SP.class, NSUpload.class})
|
@PrepareForTest({MainApp.class, SP.class, NSUpload.class})
|
||||||
public class ActionNotificationTest {
|
public class ActionNotificationTest {
|
||||||
|
@ -85,7 +73,6 @@ public class ActionNotificationTest {
|
||||||
AAPSMocker.mockMainApp();
|
AAPSMocker.mockMainApp();
|
||||||
AAPSMocker.mockSP();
|
AAPSMocker.mockSP();
|
||||||
AAPSMocker.mockStrings();
|
AAPSMocker.mockStrings();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
AAPSMocker.mockNSUpload();
|
AAPSMocker.mockNSUpload();
|
||||||
|
|
||||||
actionNotification = new ActionNotification();
|
actionNotification = new ActionNotification();
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.actions;
|
package info.nightscout.androidaps.plugins.general.automation.actions;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.squareup.otto.Bus;
|
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
@ -20,7 +19,7 @@ import info.nightscout.androidaps.queue.Callback;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({MainApp.class, SP.class, Bus.class, ProfileFunctions.class})
|
@PrepareForTest({MainApp.class, SP.class, ProfileFunctions.class})
|
||||||
public class ActionProfileSwitchPercentTest {
|
public class ActionProfileSwitchPercentTest {
|
||||||
private ActionProfileSwitchPercent actionProfileSwitchPercent;
|
private ActionProfileSwitchPercent actionProfileSwitchPercent;
|
||||||
|
|
||||||
|
@ -77,7 +76,6 @@ public class ActionProfileSwitchPercentTest {
|
||||||
public void prepareTest() {
|
public void prepareTest() {
|
||||||
AAPSMocker.mockMainApp();
|
AAPSMocker.mockMainApp();
|
||||||
AAPSMocker.mockSP();
|
AAPSMocker.mockSP();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
AAPSMocker.mockStrings();
|
AAPSMocker.mockStrings();
|
||||||
AAPSMocker.mockProfileFunctions();
|
AAPSMocker.mockProfileFunctions();
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,6 @@ public class ActionProfileSwitchTest {
|
||||||
AAPSMocker.mockApplicationContext();
|
AAPSMocker.mockApplicationContext();
|
||||||
AAPSMocker.mockStrings();
|
AAPSMocker.mockStrings();
|
||||||
AAPSMocker.mockTreatmentService();
|
AAPSMocker.mockTreatmentService();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
AAPSMocker.mockDatabaseHelper();
|
AAPSMocker.mockDatabaseHelper();
|
||||||
AAPSMocker.mockProfileFunctions();
|
AAPSMocker.mockProfileFunctions();
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,6 @@ public class ActionSendSMSTest {
|
||||||
@Before
|
@Before
|
||||||
public void prepareTest() {
|
public void prepareTest() {
|
||||||
AAPSMocker.mockMainApp();
|
AAPSMocker.mockMainApp();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
AAPSMocker.mockSP();
|
AAPSMocker.mockSP();
|
||||||
mockStatic(SmsManager.class);
|
mockStatic(SmsManager.class);
|
||||||
SmsManager smsManager = mock(SmsManager.class);
|
SmsManager smsManager = mock(SmsManager.class);
|
||||||
|
|
|
@ -90,7 +90,6 @@ public class ActionStartTempTargetTest {
|
||||||
AAPSMocker.mockMainApp();
|
AAPSMocker.mockMainApp();
|
||||||
AAPSMocker.mockSP();
|
AAPSMocker.mockSP();
|
||||||
AAPSMocker.mockStrings();
|
AAPSMocker.mockStrings();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
AAPSMocker.mockProfileFunctions();
|
AAPSMocker.mockProfileFunctions();
|
||||||
treatmentsPlugin = AAPSMocker.mockTreatmentPlugin();
|
treatmentsPlugin = AAPSMocker.mockTreatmentPlugin();
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,6 @@ public class InputBgTest {
|
||||||
@Before
|
@Before
|
||||||
public void prepare() {
|
public void prepare() {
|
||||||
AAPSMocker.mockMainApp();
|
AAPSMocker.mockMainApp();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
AAPSMocker.mockStrings();
|
AAPSMocker.mockStrings();
|
||||||
AAPSMocker.mockProfileFunctions();
|
AAPSMocker.mockProfileFunctions();
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,6 @@ public class InputTempTargetTest {
|
||||||
@Before
|
@Before
|
||||||
public void prepare() {
|
public void prepare() {
|
||||||
AAPSMocker.mockMainApp();
|
AAPSMocker.mockMainApp();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
AAPSMocker.mockStrings();
|
AAPSMocker.mockStrings();
|
||||||
AAPSMocker.mockProfileFunctions();
|
AAPSMocker.mockProfileFunctions();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.triggers;
|
package info.nightscout.androidaps.plugins.general.automation.triggers;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.squareup.otto.Bus;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
@ -28,7 +27,7 @@ import static org.mockito.ArgumentMatchers.anyDouble;
|
||||||
import static org.powermock.api.mockito.PowerMockito.when;
|
import static org.powermock.api.mockito.PowerMockito.when;
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({MainApp.class, Bus.class, ProfileFunctions.class, DateUtil.class, IobCobCalculatorPlugin.class, SP.class})
|
@PrepareForTest({MainApp.class, ProfileFunctions.class, DateUtil.class, IobCobCalculatorPlugin.class, SP.class})
|
||||||
public class TriggerAutosensValueTest {
|
public class TriggerAutosensValueTest {
|
||||||
|
|
||||||
long now = 1514766900000L;
|
long now = 1514766900000L;
|
||||||
|
@ -115,7 +114,6 @@ public class TriggerAutosensValueTest {
|
||||||
@Before
|
@Before
|
||||||
public void mock() {
|
public void mock() {
|
||||||
AAPSMocker.mockMainApp();
|
AAPSMocker.mockMainApp();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
AAPSMocker.mockIobCobCalculatorPlugin();
|
AAPSMocker.mockIobCobCalculatorPlugin();
|
||||||
AAPSMocker.mockProfileFunctions();
|
AAPSMocker.mockProfileFunctions();
|
||||||
AAPSMocker.mockSP();
|
AAPSMocker.mockSP();
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.triggers;
|
package info.nightscout.androidaps.plugins.general.automation.triggers;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.squareup.otto.Bus;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
@ -30,7 +29,7 @@ import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import static org.powermock.api.mockito.PowerMockito.when;
|
import static org.powermock.api.mockito.PowerMockito.when;
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({MainApp.class, Bus.class, ProfileFunctions.class, DateUtil.class, IobCobCalculatorPlugin.class})
|
@PrepareForTest({MainApp.class, ProfileFunctions.class, DateUtil.class, IobCobCalculatorPlugin.class})
|
||||||
public class TriggerBgTest {
|
public class TriggerBgTest {
|
||||||
|
|
||||||
long now = 1514766900000L;
|
long now = 1514766900000L;
|
||||||
|
@ -112,7 +111,6 @@ public class TriggerBgTest {
|
||||||
@Before
|
@Before
|
||||||
public void mock() {
|
public void mock() {
|
||||||
AAPSMocker.mockMainApp();
|
AAPSMocker.mockMainApp();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
AAPSMocker.mockIobCobCalculatorPlugin();
|
AAPSMocker.mockIobCobCalculatorPlugin();
|
||||||
AAPSMocker.mockProfileFunctions();
|
AAPSMocker.mockProfileFunctions();
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.triggers;
|
package info.nightscout.androidaps.plugins.general.automation.triggers;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.squareup.otto.Bus;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
@ -25,7 +24,7 @@ import static org.mockito.ArgumentMatchers.anyDouble;
|
||||||
import static org.powermock.api.mockito.PowerMockito.when;
|
import static org.powermock.api.mockito.PowerMockito.when;
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({MainApp.class, Bus.class, ProfileFunctions.class, DateUtil.class, TreatmentsPlugin.class})
|
@PrepareForTest({MainApp.class, ProfileFunctions.class, DateUtil.class, TreatmentsPlugin.class})
|
||||||
public class TriggerBolusAgoTest {
|
public class TriggerBolusAgoTest {
|
||||||
|
|
||||||
long now = 1514766900000L;
|
long now = 1514766900000L;
|
||||||
|
@ -109,7 +108,6 @@ public class TriggerBolusAgoTest {
|
||||||
@Before
|
@Before
|
||||||
public void mock() {
|
public void mock() {
|
||||||
AAPSMocker.mockMainApp();
|
AAPSMocker.mockMainApp();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
AAPSMocker.mockProfileFunctions();
|
AAPSMocker.mockProfileFunctions();
|
||||||
PowerMockito.mockStatic(DateUtil.class);
|
PowerMockito.mockStatic(DateUtil.class);
|
||||||
AAPSMocker.mockTreatmentPlugin();
|
AAPSMocker.mockTreatmentPlugin();
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.triggers;
|
package info.nightscout.androidaps.plugins.general.automation.triggers;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.squareup.otto.Bus;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
@ -16,8 +15,6 @@ import org.powermock.modules.junit4.PowerMockRunner;
|
||||||
import info.AAPSMocker;
|
import info.AAPSMocker;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.IobTotal;
|
|
||||||
import info.nightscout.androidaps.data.Profile;
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.Comparator;
|
import info.nightscout.androidaps.plugins.general.automation.elements.Comparator;
|
||||||
|
@ -27,12 +24,10 @@ import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.anyLong;
|
|
||||||
import static org.powermock.api.mockito.PowerMockito.verifyNew;
|
|
||||||
import static org.powermock.api.mockito.PowerMockito.when;
|
import static org.powermock.api.mockito.PowerMockito.when;
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({MainApp.class, Bus.class, ProfileFunctions.class, DateUtil.class, IobCobCalculatorPlugin.class, SP.class, L.class})
|
@PrepareForTest({MainApp.class, ProfileFunctions.class, DateUtil.class, IobCobCalculatorPlugin.class, SP.class, L.class})
|
||||||
public class TriggerCOBTest {
|
public class TriggerCOBTest {
|
||||||
|
|
||||||
long now = 1514766900000L;
|
long now = 1514766900000L;
|
||||||
|
@ -104,7 +99,6 @@ public class TriggerCOBTest {
|
||||||
@Before
|
@Before
|
||||||
public void mock() {
|
public void mock() {
|
||||||
AAPSMocker.mockMainApp();
|
AAPSMocker.mockMainApp();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
iobCobCalculatorPlugin = AAPSMocker.mockIobCobCalculatorPlugin();
|
iobCobCalculatorPlugin = AAPSMocker.mockIobCobCalculatorPlugin();
|
||||||
AAPSMocker.mockProfileFunctions();
|
AAPSMocker.mockProfileFunctions();
|
||||||
AAPSMocker.mockSP();
|
AAPSMocker.mockSP();
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.triggers;
|
package info.nightscout.androidaps.plugins.general.automation.triggers;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.squareup.otto.Bus;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
@ -32,7 +31,7 @@ import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import static org.powermock.api.mockito.PowerMockito.when;
|
import static org.powermock.api.mockito.PowerMockito.when;
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({MainApp.class, Bus.class, ProfileFunctions.class, DateUtil.class, IobCobCalculatorPlugin.class, GlucoseStatus.class})
|
@PrepareForTest({MainApp.class, ProfileFunctions.class, DateUtil.class, IobCobCalculatorPlugin.class, GlucoseStatus.class})
|
||||||
public class TriggerDeltaTest {
|
public class TriggerDeltaTest {
|
||||||
|
|
||||||
long now = 1514766900000L;
|
long now = 1514766900000L;
|
||||||
|
@ -122,7 +121,6 @@ public class TriggerDeltaTest {
|
||||||
@Before
|
@Before
|
||||||
public void mock() {
|
public void mock() {
|
||||||
AAPSMocker.mockMainApp();
|
AAPSMocker.mockMainApp();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
AAPSMocker.mockIobCobCalculatorPlugin();
|
AAPSMocker.mockIobCobCalculatorPlugin();
|
||||||
AAPSMocker.mockProfileFunctions();
|
AAPSMocker.mockProfileFunctions();
|
||||||
AAPSMocker.mockApplicationContext();
|
AAPSMocker.mockApplicationContext();
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.triggers;
|
package info.nightscout.androidaps.plugins.general.automation.triggers;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.squareup.otto.Bus;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
@ -28,7 +27,7 @@ import static org.mockito.ArgumentMatchers.anyLong;
|
||||||
import static org.powermock.api.mockito.PowerMockito.when;
|
import static org.powermock.api.mockito.PowerMockito.when;
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({MainApp.class, Bus.class, ProfileFunctions.class, DateUtil.class, IobCobCalculatorPlugin.class})
|
@PrepareForTest({MainApp.class, ProfileFunctions.class, DateUtil.class, IobCobCalculatorPlugin.class})
|
||||||
public class TriggerIobTest {
|
public class TriggerIobTest {
|
||||||
|
|
||||||
long now = 1514766900000L;
|
long now = 1514766900000L;
|
||||||
|
@ -103,7 +102,6 @@ public class TriggerIobTest {
|
||||||
@Before
|
@Before
|
||||||
public void mock() {
|
public void mock() {
|
||||||
AAPSMocker.mockMainApp();
|
AAPSMocker.mockMainApp();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
iobCobCalculatorPlugin = AAPSMocker.mockIobCobCalculatorPlugin();
|
iobCobCalculatorPlugin = AAPSMocker.mockIobCobCalculatorPlugin();
|
||||||
AAPSMocker.mockProfileFunctions();
|
AAPSMocker.mockProfileFunctions();
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ package info.nightscout.androidaps.plugins.general.automation.triggers;
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.squareup.otto.Bus;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
@ -26,7 +25,7 @@ import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import static org.powermock.api.mockito.PowerMockito.when;
|
import static org.powermock.api.mockito.PowerMockito.when;
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({MainApp.class, Bus.class, ProfileFunctions.class, DateUtil.class, LocationService.class})
|
@PrepareForTest({MainApp.class, ProfileFunctions.class, DateUtil.class, LocationService.class})
|
||||||
|
|
||||||
public class TriggerLocationTest {
|
public class TriggerLocationTest {
|
||||||
|
|
||||||
|
@ -35,7 +34,6 @@ public class TriggerLocationTest {
|
||||||
@Before
|
@Before
|
||||||
public void mock() {
|
public void mock() {
|
||||||
AAPSMocker.mockMainApp();
|
AAPSMocker.mockMainApp();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
AAPSMocker.mockApplicationContext();
|
AAPSMocker.mockApplicationContext();
|
||||||
|
|
||||||
PowerMockito.mockStatic(DateUtil.class);
|
PowerMockito.mockStatic(DateUtil.class);
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.triggers;
|
package info.nightscout.androidaps.plugins.general.automation.triggers;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.squareup.otto.Bus;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
@ -24,7 +23,7 @@ import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import static org.powermock.api.mockito.PowerMockito.when;
|
import static org.powermock.api.mockito.PowerMockito.when;
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({MainApp.class, Bus.class, ProfileFunctions.class, DateUtil.class, L.class})
|
@PrepareForTest({MainApp.class, ProfileFunctions.class, DateUtil.class, L.class})
|
||||||
public class TriggerProfilePercentTest {
|
public class TriggerProfilePercentTest {
|
||||||
|
|
||||||
private long now = 1514766900000L;
|
private long now = 1514766900000L;
|
||||||
|
@ -102,7 +101,6 @@ public class TriggerProfilePercentTest {
|
||||||
@Before
|
@Before
|
||||||
public void mock() {
|
public void mock() {
|
||||||
AAPSMocker.mockMainApp();
|
AAPSMocker.mockMainApp();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
AAPSMocker.mockProfileFunctions();
|
AAPSMocker.mockProfileFunctions();
|
||||||
AAPSMocker.mockL();
|
AAPSMocker.mockL();
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.triggers;
|
package info.nightscout.androidaps.plugins.general.automation.triggers;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.squareup.otto.Bus;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
@ -26,7 +25,7 @@ import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import static org.powermock.api.mockito.PowerMockito.when;
|
import static org.powermock.api.mockito.PowerMockito.when;
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({MainApp.class, Bus.class, ProfileFunctions.class, DateUtil.class, TreatmentsPlugin.class, ConfigBuilderPlugin.class, System.class})
|
@PrepareForTest({MainApp.class, ProfileFunctions.class, DateUtil.class, TreatmentsPlugin.class, ConfigBuilderPlugin.class, System.class})
|
||||||
public class TriggerPumpLastConnectionTest {
|
public class TriggerPumpLastConnectionTest {
|
||||||
|
|
||||||
long now = 1514766900000L;
|
long now = 1514766900000L;
|
||||||
|
@ -103,7 +102,6 @@ public class TriggerPumpLastConnectionTest {
|
||||||
public void mock() {
|
public void mock() {
|
||||||
AAPSMocker.mockMainApp();
|
AAPSMocker.mockMainApp();
|
||||||
AAPSMocker.mockConfigBuilder();
|
AAPSMocker.mockConfigBuilder();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
PowerMockito.mockStatic(DateUtil.class);
|
PowerMockito.mockStatic(DateUtil.class);
|
||||||
when(DateUtil.now()).thenReturn(now);
|
when(DateUtil.now()).thenReturn(now);
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.triggers;
|
package info.nightscout.androidaps.plugins.general.automation.triggers;
|
||||||
|
|
||||||
import com.squareup.otto.Bus;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
@ -22,7 +20,7 @@ import info.nightscout.androidaps.utils.T;
|
||||||
import static org.powermock.api.mockito.PowerMockito.when;
|
import static org.powermock.api.mockito.PowerMockito.when;
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({MainApp.class, Bus.class, DateUtil.class, GregorianCalendar.class})
|
@PrepareForTest({MainApp.class, DateUtil.class, GregorianCalendar.class})
|
||||||
public class TriggerRecurringTimeTest {
|
public class TriggerRecurringTimeTest {
|
||||||
|
|
||||||
long now = 1514766900000L;
|
long now = 1514766900000L;
|
||||||
|
@ -65,7 +63,6 @@ public class TriggerRecurringTimeTest {
|
||||||
@Before
|
@Before
|
||||||
public void mock() {
|
public void mock() {
|
||||||
AAPSMocker.mockMainApp();
|
AAPSMocker.mockMainApp();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
|
|
||||||
PowerMockito.mockStatic(DateUtil.class);
|
PowerMockito.mockStatic(DateUtil.class);
|
||||||
when(DateUtil.now()).thenReturn(now);
|
when(DateUtil.now()).thenReturn(now);
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.triggers;
|
package info.nightscout.androidaps.plugins.general.automation.triggers;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.squareup.otto.Bus;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
@ -22,11 +21,10 @@ import info.nightscout.androidaps.plugins.general.automation.elements.Comparator
|
||||||
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 static org.mockito.ArgumentMatchers.any;
|
|
||||||
import static org.powermock.api.mockito.PowerMockito.when;
|
import static org.powermock.api.mockito.PowerMockito.when;
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({MainApp.class, Bus.class, ProfileFunctions.class, DateUtil.class, TreatmentsPlugin.class})
|
@PrepareForTest({MainApp.class, ProfileFunctions.class, DateUtil.class, TreatmentsPlugin.class})
|
||||||
public class TriggerTempTargetTest {
|
public class TriggerTempTargetTest {
|
||||||
|
|
||||||
TreatmentsPlugin treatmentsPlugin;
|
TreatmentsPlugin treatmentsPlugin;
|
||||||
|
@ -86,7 +84,6 @@ public class TriggerTempTargetTest {
|
||||||
@Before
|
@Before
|
||||||
public void mock() {
|
public void mock() {
|
||||||
AAPSMocker.mockMainApp();
|
AAPSMocker.mockMainApp();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
treatmentsPlugin = AAPSMocker.mockTreatmentPlugin();
|
treatmentsPlugin = AAPSMocker.mockTreatmentPlugin();
|
||||||
|
|
||||||
PowerMockito.mockStatic(DateUtil.class);
|
PowerMockito.mockStatic(DateUtil.class);
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.triggers;
|
package info.nightscout.androidaps.plugins.general.automation.triggers;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.squareup.otto.Bus;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
@ -19,12 +18,11 @@ import info.AAPSMocker;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.T;
|
|
||||||
|
|
||||||
import static org.powermock.api.mockito.PowerMockito.when;
|
import static org.powermock.api.mockito.PowerMockito.when;
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({MainApp.class, Bus.class, DateUtil.class, GregorianCalendar.class})
|
@PrepareForTest({MainApp.class, DateUtil.class, GregorianCalendar.class})
|
||||||
public class TriggerTimeRangeTest {
|
public class TriggerTimeRangeTest {
|
||||||
|
|
||||||
int now = 754;
|
int now = 754;
|
||||||
|
@ -98,7 +96,6 @@ public class TriggerTimeRangeTest {
|
||||||
@Before
|
@Before
|
||||||
public void mock() {
|
public void mock() {
|
||||||
AAPSMocker.mockMainApp();
|
AAPSMocker.mockMainApp();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
|
|
||||||
PowerMockito.mockStatic(DateUtil.class);
|
PowerMockito.mockStatic(DateUtil.class);
|
||||||
when(DateUtil.now()).thenReturn((long) now * 60000);
|
when(DateUtil.now()).thenReturn((long) now * 60000);
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.triggers;
|
package info.nightscout.androidaps.plugins.general.automation.triggers;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.squareup.otto.Bus;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
@ -24,7 +23,7 @@ import info.nightscout.androidaps.utils.T;
|
||||||
import static org.powermock.api.mockito.PowerMockito.when;
|
import static org.powermock.api.mockito.PowerMockito.when;
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({MainApp.class, Bus.class, DateUtil.class, GregorianCalendar.class})
|
@PrepareForTest({MainApp.class, DateUtil.class, GregorianCalendar.class})
|
||||||
public class TriggerTimeTest {
|
public class TriggerTimeTest {
|
||||||
|
|
||||||
long now = 1514766900000L;
|
long now = 1514766900000L;
|
||||||
|
@ -90,7 +89,6 @@ public class TriggerTimeTest {
|
||||||
@Before
|
@Before
|
||||||
public void mock() {
|
public void mock() {
|
||||||
AAPSMocker.mockMainApp();
|
AAPSMocker.mockMainApp();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
|
|
||||||
PowerMockito.mockStatic(DateUtil.class);
|
PowerMockito.mockStatic(DateUtil.class);
|
||||||
when(DateUtil.now()).thenReturn(now);
|
when(DateUtil.now()).thenReturn(now);
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.triggers;
|
package info.nightscout.androidaps.plugins.general.automation.triggers;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.squareup.otto.Bus;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
@ -24,7 +23,7 @@ import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import static org.powermock.api.mockito.PowerMockito.when;
|
import static org.powermock.api.mockito.PowerMockito.when;
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({MainApp.class, Bus.class, NetworkChangeReceiver.class, DateUtil.class})
|
@PrepareForTest({MainApp.class, NetworkChangeReceiver.class, DateUtil.class})
|
||||||
public class TriggerWifiSsidTest {
|
public class TriggerWifiSsidTest {
|
||||||
|
|
||||||
long now = 1514766900000L;
|
long now = 1514766900000L;
|
||||||
|
@ -102,7 +101,6 @@ public class TriggerWifiSsidTest {
|
||||||
@Before
|
@Before
|
||||||
public void mock() {
|
public void mock() {
|
||||||
AAPSMocker.mockMainApp();
|
AAPSMocker.mockMainApp();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
|
|
||||||
PowerMockito.mockStatic(NetworkChangeReceiver.class);
|
PowerMockito.mockStatic(NetworkChangeReceiver.class);
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,6 @@ public class NewNSTreatmentDialogTest {
|
||||||
AAPSMocker.mockStrings();
|
AAPSMocker.mockStrings();
|
||||||
PowerMockito.mockStatic(NSUpload.class);
|
PowerMockito.mockStatic(NSUpload.class);
|
||||||
AAPSMocker.mockTreatmentService();
|
AAPSMocker.mockTreatmentService();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
AAPSMocker.mockDatabaseHelper();
|
AAPSMocker.mockDatabaseHelper();
|
||||||
|
|
||||||
NSProfilePlugin profilePlugin = NSProfilePlugin.getPlugin();
|
NSProfilePlugin profilePlugin = NSProfilePlugin.getPlugin();
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.general.nsclient;
|
package info.nightscout.androidaps.plugins.general.nsclient;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import com.squareup.otto.Bus;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -34,10 +33,9 @@ public class NsClientReceiverDelegateTest {
|
||||||
AAPSMocker.mockMainApp();
|
AAPSMocker.mockMainApp();
|
||||||
AAPSMocker.mockApplicationContext();
|
AAPSMocker.mockApplicationContext();
|
||||||
|
|
||||||
Bus bus = MainApp.bus();
|
|
||||||
Context context = MainApp.instance().getApplicationContext();
|
Context context = MainApp.instance().getApplicationContext();
|
||||||
|
|
||||||
sut = new NsClientReceiverDelegate(context, bus);
|
sut = new NsClientReceiverDelegate(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -718,7 +718,6 @@ public class SmsCommunicatorPluginTest {
|
||||||
AAPSMocker.mockSP();
|
AAPSMocker.mockSP();
|
||||||
AAPSMocker.mockL();
|
AAPSMocker.mockL();
|
||||||
AAPSMocker.mockStrings();
|
AAPSMocker.mockStrings();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
AAPSMocker.mockProfileFunctions();
|
AAPSMocker.mockProfileFunctions();
|
||||||
AAPSMocker.mockTreatmentPlugin();
|
AAPSMocker.mockTreatmentPlugin();
|
||||||
AAPSMocker.mockTreatmentService();
|
AAPSMocker.mockTreatmentService();
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package info.nightscout.androidaps.plugins.general.versionChecker
|
package info.nightscout.androidaps.plugins.general.versionChecker
|
||||||
|
|
||||||
import com.squareup.otto.Bus
|
|
||||||
import info.nightscout.androidaps.MainApp
|
import info.nightscout.androidaps.MainApp
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.logging.L
|
import info.nightscout.androidaps.logging.L
|
||||||
|
@ -63,7 +62,7 @@ class VersionCheckerUtilsKtTest {
|
||||||
@Test
|
@Test
|
||||||
@PrepareForTest(MainApp::class, L::class, SP::class)
|
@PrepareForTest(MainApp::class, L::class, SP::class)
|
||||||
fun `should find update1`() {
|
fun `should find update1`() {
|
||||||
val bus = prepareBus()
|
prepareMainApp()
|
||||||
|
|
||||||
compareWithCurrentVersion(newVersion = "2.2.3", currentVersion = "2.2.1")
|
compareWithCurrentVersion(newVersion = "2.2.3", currentVersion = "2.2.1")
|
||||||
|
|
||||||
|
@ -80,7 +79,7 @@ class VersionCheckerUtilsKtTest {
|
||||||
@Test
|
@Test
|
||||||
@PrepareForTest(MainApp::class, L::class, SP::class)
|
@PrepareForTest(MainApp::class, L::class, SP::class)
|
||||||
fun `should find update2`() {
|
fun `should find update2`() {
|
||||||
val bus = prepareBus()
|
prepareMainApp()
|
||||||
|
|
||||||
compareWithCurrentVersion(newVersion = "2.2.3", currentVersion = "2.2.1-dev")
|
compareWithCurrentVersion(newVersion = "2.2.3", currentVersion = "2.2.1-dev")
|
||||||
|
|
||||||
|
@ -96,7 +95,7 @@ class VersionCheckerUtilsKtTest {
|
||||||
@Test
|
@Test
|
||||||
@PrepareForTest(MainApp::class, L::class, SP::class)
|
@PrepareForTest(MainApp::class, L::class, SP::class)
|
||||||
fun `should find update3`() {
|
fun `should find update3`() {
|
||||||
val bus = prepareBus()
|
prepareMainApp()
|
||||||
|
|
||||||
compareWithCurrentVersion(newVersion = "2.2.3", currentVersion = "2.1")
|
compareWithCurrentVersion(newVersion = "2.2.3", currentVersion = "2.1")
|
||||||
|
|
||||||
|
@ -112,7 +111,7 @@ class VersionCheckerUtilsKtTest {
|
||||||
@Test
|
@Test
|
||||||
@PrepareForTest(MainApp::class, L::class, SP::class)
|
@PrepareForTest(MainApp::class, L::class, SP::class)
|
||||||
fun `should find update4`() {
|
fun `should find update4`() {
|
||||||
val bus = prepareBus()
|
prepareMainApp()
|
||||||
|
|
||||||
compareWithCurrentVersion(newVersion = "2.2", currentVersion = "2.1.1")
|
compareWithCurrentVersion(newVersion = "2.2", currentVersion = "2.1.1")
|
||||||
|
|
||||||
|
@ -128,7 +127,7 @@ class VersionCheckerUtilsKtTest {
|
||||||
@Test
|
@Test
|
||||||
@PrepareForTest(MainApp::class, L::class, SP::class)
|
@PrepareForTest(MainApp::class, L::class, SP::class)
|
||||||
fun `should find update5`() {
|
fun `should find update5`() {
|
||||||
val bus = prepareBus()
|
prepareMainApp()
|
||||||
compareWithCurrentVersion(newVersion = "2.2.1", currentVersion = "2.2-dev")
|
compareWithCurrentVersion(newVersion = "2.2.1", currentVersion = "2.2-dev")
|
||||||
|
|
||||||
//verify(bus, times(1)).post(any())
|
//verify(bus, times(1)).post(any())
|
||||||
|
@ -143,7 +142,7 @@ class VersionCheckerUtilsKtTest {
|
||||||
@Test
|
@Test
|
||||||
@PrepareForTest(MainApp::class, L::class, SP::class)
|
@PrepareForTest(MainApp::class, L::class, SP::class)
|
||||||
fun `should find update6`() {
|
fun `should find update6`() {
|
||||||
val bus = prepareBus()
|
prepareMainApp()
|
||||||
compareWithCurrentVersion(newVersion = "2.2.1", currentVersion = "2.2dev")
|
compareWithCurrentVersion(newVersion = "2.2.1", currentVersion = "2.2dev")
|
||||||
|
|
||||||
//verify(bus, times(1)).post(any())
|
//verify(bus, times(1)).post(any())
|
||||||
|
@ -165,10 +164,10 @@ class VersionCheckerUtilsKtTest {
|
||||||
| version = "2.2.2"
|
| version = "2.2.2"
|
||||||
| appName = "Aaoeu"
|
| appName = "Aaoeu"
|
||||||
""".trimMargin()
|
""".trimMargin()
|
||||||
val bus = prepareBus()
|
prepareMainApp()
|
||||||
compareWithCurrentVersion(findVersion(buildGradle), currentVersion = "2.2.2")
|
compareWithCurrentVersion(findVersion(buildGradle), currentVersion = "2.2.2")
|
||||||
|
|
||||||
verify(bus, times(0)).post(any())
|
//verify(bus, times(0)).post(any())
|
||||||
|
|
||||||
PowerMockito.verifyStatic(SP::class.java, times(1))
|
PowerMockito.verifyStatic(SP::class.java, times(1))
|
||||||
SP.putLong(eq(R.string.key_last_time_this_version_detected), ArgumentMatchers.anyLong())
|
SP.putLong(eq(R.string.key_last_time_this_version_detected), ArgumentMatchers.anyLong())
|
||||||
|
@ -185,11 +184,9 @@ class VersionCheckerUtilsKtTest {
|
||||||
| version = "3.0"
|
| version = "3.0"
|
||||||
| appName = "Aaoeu"
|
| appName = "Aaoeu"
|
||||||
""".trimMargin()
|
""".trimMargin()
|
||||||
val bus = prepareBus()
|
prepareMainApp()
|
||||||
compareWithCurrentVersion(findVersion(buildGradle), currentVersion = "2.2.2")
|
compareWithCurrentVersion(findVersion(buildGradle), currentVersion = "2.2.2")
|
||||||
|
|
||||||
//verify(bus, times(1)).post(any())
|
|
||||||
|
|
||||||
PowerMockito.verifyStatic(SP::class.java, times(1))
|
PowerMockito.verifyStatic(SP::class.java, times(1))
|
||||||
SP.getLong(eq(R.string.key_last_versionchecker_warning), ArgumentMatchers.anyLong())
|
SP.getLong(eq(R.string.key_last_versionchecker_warning), ArgumentMatchers.anyLong())
|
||||||
PowerMockito.verifyStatic(SP::class.java, times(1))
|
PowerMockito.verifyStatic(SP::class.java, times(1))
|
||||||
|
@ -207,15 +204,12 @@ class VersionCheckerUtilsKtTest {
|
||||||
assertEquals(100L, System.currentTimeMillis())
|
assertEquals(100L, System.currentTimeMillis())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun prepareBus(): Bus {
|
private fun prepareMainApp() {
|
||||||
PowerMockito.mockStatic(MainApp::class.java)
|
PowerMockito.mockStatic(MainApp::class.java)
|
||||||
val mainApp = mock<MainApp>(MainApp::class.java)
|
val mainApp = mock<MainApp>(MainApp::class.java)
|
||||||
`when`(MainApp.instance()).thenReturn(mainApp)
|
`when`(MainApp.instance()).thenReturn(mainApp)
|
||||||
val bus = mock(Bus::class.java)
|
|
||||||
`when`(MainApp.bus()).thenReturn(bus)
|
|
||||||
`when`(MainApp.gs(ArgumentMatchers.anyInt())).thenReturn("some dummy string")
|
`when`(MainApp.gs(ArgumentMatchers.anyInt())).thenReturn("some dummy string")
|
||||||
prepareSP()
|
prepareSP()
|
||||||
return bus
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun prepareSP() {
|
private fun prepareSP() {
|
||||||
|
|
|
@ -62,7 +62,6 @@ public class ComboPluginTest {
|
||||||
public void prepareMocks() throws Exception {
|
public void prepareMocks() throws Exception {
|
||||||
AAPSMocker.mockMainApp();
|
AAPSMocker.mockMainApp();
|
||||||
AAPSMocker.mockConfigBuilder();
|
AAPSMocker.mockConfigBuilder();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
AAPSMocker.mockStrings();
|
AAPSMocker.mockStrings();
|
||||||
AAPSMocker.mockCommandQueue();
|
AAPSMocker.mockCommandQueue();
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,6 @@ public class DanaRPluginTest {
|
||||||
public void prepareMocks() throws Exception {
|
public void prepareMocks() throws Exception {
|
||||||
AAPSMocker.mockMainApp();
|
AAPSMocker.mockMainApp();
|
||||||
AAPSMocker.mockConfigBuilder();
|
AAPSMocker.mockConfigBuilder();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
AAPSMocker.mockStrings();
|
AAPSMocker.mockStrings();
|
||||||
AAPSMocker.mockApplicationContext();
|
AAPSMocker.mockApplicationContext();
|
||||||
AAPSMocker.mockSP();
|
AAPSMocker.mockSP();
|
||||||
|
|
|
@ -11,7 +11,7 @@ import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.treatments.Treatment;
|
import info.nightscout.androidaps.plugins.treatments.Treatment;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Rumen Georgiev on 8/28/2018.
|
* Created by Rumen Georgiev on 8/28/2018.
|
||||||
|
@ -27,7 +27,6 @@ public class MsgBolusProgressTest {
|
||||||
AAPSMocker.mockSP();
|
AAPSMocker.mockSP();
|
||||||
AAPSMocker.mockL();
|
AAPSMocker.mockL();
|
||||||
AAPSMocker.mockStrings();
|
AAPSMocker.mockStrings();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
Treatment t = new Treatment();
|
Treatment t = new Treatment();
|
||||||
MsgBolusProgress packet = new MsgBolusProgress(3D, t);
|
MsgBolusProgress packet = new MsgBolusProgress(3D, t);
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.treatments.Treatment;
|
import info.nightscout.androidaps.plugins.treatments.Treatment;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Rumen Georgiev on 8/28/2018.
|
* Created by Rumen Georgiev on 8/28/2018.
|
||||||
|
@ -26,7 +26,7 @@ public class MsgBolusStopTest {
|
||||||
AAPSMocker.mockApplicationContext();
|
AAPSMocker.mockApplicationContext();
|
||||||
AAPSMocker.mockSP();
|
AAPSMocker.mockSP();
|
||||||
AAPSMocker.mockL();
|
AAPSMocker.mockL();
|
||||||
AAPSMocker.mockBus();
|
AAPSMocker.mockStrings();
|
||||||
Treatment t = new Treatment();
|
Treatment t = new Treatment();
|
||||||
MsgBolusStop packet = new MsgBolusStop(1d,t);
|
MsgBolusStop packet = new MsgBolusStop(1d,t);
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump;
|
||||||
import info.nightscout.androidaps.plugins.treatments.Treatment;
|
import info.nightscout.androidaps.plugins.treatments.Treatment;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Rumen Georgiev on 8/28/2018.
|
* Created by Rumen Georgiev on 8/28/2018.
|
||||||
|
@ -28,7 +28,6 @@ public class MsgCheckValueTest {
|
||||||
AAPSMocker.mockApplicationContext();
|
AAPSMocker.mockApplicationContext();
|
||||||
AAPSMocker.mockSP();
|
AAPSMocker.mockSP();
|
||||||
AAPSMocker.mockL();
|
AAPSMocker.mockL();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
Treatment t = new Treatment();
|
Treatment t = new Treatment();
|
||||||
MsgCheckValue packet = new MsgCheckValue();
|
MsgCheckValue packet = new MsgCheckValue();
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Rumen Georgiev on 8/28/2018.
|
* Created by Rumen Georgiev on 8/28/2018.
|
||||||
|
@ -26,7 +26,6 @@ public class MsgErrorTest {
|
||||||
AAPSMocker.mockApplicationContext();
|
AAPSMocker.mockApplicationContext();
|
||||||
AAPSMocker.mockSP();
|
AAPSMocker.mockSP();
|
||||||
AAPSMocker.mockL();
|
AAPSMocker.mockL();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
AAPSMocker.mockNSUpload();
|
AAPSMocker.mockNSUpload();
|
||||||
MsgError packet = new MsgError();
|
MsgError packet = new MsgError();
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Rumen Georgiev on 8/30/2018.
|
* Created by Rumen Georgiev on 8/30/2018.
|
||||||
|
@ -26,7 +26,6 @@ public class MsgHistoryAllTest {
|
||||||
AAPSMocker.mockApplicationContext();
|
AAPSMocker.mockApplicationContext();
|
||||||
AAPSMocker.mockSP();
|
AAPSMocker.mockSP();
|
||||||
AAPSMocker.mockL();
|
AAPSMocker.mockL();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
AAPSMocker.mockDatabaseHelper();
|
AAPSMocker.mockDatabaseHelper();
|
||||||
MsgHistoryAll packet = new MsgHistoryAll();
|
MsgHistoryAll packet = new MsgHistoryAll();
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,6 @@ public class MsgInitConnStatusBolusTest {
|
||||||
AAPSMocker.mockApplicationContext();
|
AAPSMocker.mockApplicationContext();
|
||||||
AAPSMocker.mockSP();
|
AAPSMocker.mockSP();
|
||||||
AAPSMocker.mockL();
|
AAPSMocker.mockL();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
MsgInitConnStatusBolus packet = new MsgInitConnStatusBolus();
|
MsgInitConnStatusBolus packet = new MsgInitConnStatusBolus();
|
||||||
|
|
||||||
// test message decoding
|
// test message decoding
|
||||||
|
|
|
@ -27,7 +27,6 @@ public class MsgInitConnStatusOptionTest {
|
||||||
AAPSMocker.mockApplicationContext();
|
AAPSMocker.mockApplicationContext();
|
||||||
AAPSMocker.mockSP();
|
AAPSMocker.mockSP();
|
||||||
AAPSMocker.mockL();
|
AAPSMocker.mockL();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
AAPSMocker.mockConfigBuilder();
|
AAPSMocker.mockConfigBuilder();
|
||||||
MsgInitConnStatusOption packet = new MsgInitConnStatusOption();
|
MsgInitConnStatusOption packet = new MsgInitConnStatusOption();
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Rumen Georgiev on 8/30/2018.
|
* Created by Rumen Georgiev on 8/30/2018.
|
||||||
|
@ -26,7 +26,6 @@ public class MsgInitConnStatusTimeTest {
|
||||||
AAPSMocker.mockApplicationContext();
|
AAPSMocker.mockApplicationContext();
|
||||||
AAPSMocker.mockSP();
|
AAPSMocker.mockSP();
|
||||||
AAPSMocker.mockL();
|
AAPSMocker.mockL();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
AAPSMocker.mockConfigBuilder();
|
AAPSMocker.mockConfigBuilder();
|
||||||
AAPSMocker.mockCommandQueue();
|
AAPSMocker.mockCommandQueue();
|
||||||
AAPSMocker.mockDanaRPlugin();
|
AAPSMocker.mockDanaRPlugin();
|
||||||
|
|
|
@ -25,7 +25,6 @@ public class MsgSetBasalProfileTest {
|
||||||
AAPSMocker.mockApplicationContext();
|
AAPSMocker.mockApplicationContext();
|
||||||
AAPSMocker.mockSP();
|
AAPSMocker.mockSP();
|
||||||
AAPSMocker.mockL();
|
AAPSMocker.mockL();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
MsgSetBasalProfile packet = new MsgSetBasalProfile((byte) 1, createArray(24,1));
|
MsgSetBasalProfile packet = new MsgSetBasalProfile((byte) 1, createArray(24,1));
|
||||||
|
|
||||||
// test message decoding
|
// test message decoding
|
||||||
|
|
|
@ -25,7 +25,6 @@ public class MsgSetSingleBasalProfileTest {
|
||||||
AAPSMocker.mockApplicationContext();
|
AAPSMocker.mockApplicationContext();
|
||||||
AAPSMocker.mockSP();
|
AAPSMocker.mockSP();
|
||||||
AAPSMocker.mockL();
|
AAPSMocker.mockL();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
MsgSetSingleBasalProfile packet = new MsgSetSingleBasalProfile(createArray(24, 2));
|
MsgSetSingleBasalProfile packet = new MsgSetSingleBasalProfile(createArray(24, 2));
|
||||||
|
|
||||||
// test message decoding
|
// test message decoding
|
||||||
|
|
|
@ -26,7 +26,6 @@ public class MsgSettingMealTest {
|
||||||
AAPSMocker.mockApplicationContext();
|
AAPSMocker.mockApplicationContext();
|
||||||
AAPSMocker.mockSP();
|
AAPSMocker.mockSP();
|
||||||
AAPSMocker.mockL();
|
AAPSMocker.mockL();
|
||||||
AAPSMocker.mockBus();
|
|
||||||
MsgSettingMeal packet = new MsgSettingMeal();
|
MsgSettingMeal packet = new MsgSettingMeal();
|
||||||
|
|
||||||
// test message decoding
|
// test message decoding
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue