Changes needed after merge (sorry I didn't test merge after I did it and there were few problems)
This commit is contained in:
parent
75d3f3b4bc
commit
43f2f69133
4 changed files with 95 additions and 41 deletions
|
@ -1,12 +1,25 @@
|
|||
package info.nightscout.androidaps;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.danlew.android.joda.JodaTimeAndroid;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import android.app.Application;
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.res.Resources;
|
||||
import android.os.SystemClock;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.PluralsRes;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
import android.util.Log;
|
||||
|
||||
import com.crashlytics.android.Crashlytics;
|
||||
import com.crashlytics.android.answers.Answers;
|
||||
|
@ -15,14 +28,6 @@ import com.squareup.otto.Bus;
|
|||
import com.squareup.otto.LoggingBus;
|
||||
import com.squareup.otto.ThreadEnforcer;
|
||||
|
||||
import net.danlew.android.joda.JodaTimeAndroid;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import info.nightscout.androidaps.data.ConstraintChecker;
|
||||
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
|
@ -39,8 +44,9 @@ import info.nightscout.androidaps.plugins.Insulin.InsulinOrefFreePeakPlugin;
|
|||
import info.nightscout.androidaps.plugins.Insulin.InsulinOrefRapidActingPlugin;
|
||||
import info.nightscout.androidaps.plugins.Insulin.InsulinOrefUltraRapidActingPlugin;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||
import info.nightscout.androidaps.plugins.Maintenance.MaintenancePlugin;
|
||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||
import info.nightscout.androidaps.plugins.Maintenance.LoggerUtils;
|
||||
import info.nightscout.androidaps.plugins.Maintenance.MaintenancePlugin;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientPlugin;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.receivers.AckAlarmReceiver;
|
||||
|
@ -54,6 +60,8 @@ import info.nightscout.androidaps.plugins.ProfileLocal.LocalProfilePlugin;
|
|||
import info.nightscout.androidaps.plugins.ProfileNS.NSProfilePlugin;
|
||||
import info.nightscout.androidaps.plugins.ProfileSimple.SimpleProfilePlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpCombo.ComboPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.RileyLinkConst;
|
||||
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.RileyLinkUtil;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaRS.DanaRSPlugin;
|
||||
|
@ -80,11 +88,10 @@ import info.nightscout.androidaps.receivers.KeepAliveReceiver;
|
|||
import info.nightscout.androidaps.receivers.NSAlarmReceiver;
|
||||
import info.nightscout.androidaps.services.Intents;
|
||||
import info.nightscout.utils.FabricPrivacy;
|
||||
import info.nightscout.androidaps.plugins.Maintenance.LoggerUtils;
|
||||
import io.fabric.sdk.android.Fabric;
|
||||
|
||||
|
||||
public class MainApp extends Application {
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(L.CORE);
|
||||
private static KeepAliveReceiver keepAliveReceiver;
|
||||
|
||||
|
@ -107,6 +114,7 @@ public class MainApp extends Application {
|
|||
public static boolean devBranch;
|
||||
public static boolean engineeringMode;
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
@ -148,7 +156,8 @@ public class MainApp extends Application {
|
|||
// Register all tabs in app here
|
||||
pluginsList.add(OverviewPlugin.getPlugin());
|
||||
pluginsList.add(IobCobCalculatorPlugin.getPlugin());
|
||||
if (Config.ACTION) pluginsList.add(ActionsFragment.getPlugin());
|
||||
if (Config.ACTION)
|
||||
pluginsList.add(ActionsFragment.getPlugin());
|
||||
pluginsList.add(InsulinOrefRapidActingPlugin.getPlugin());
|
||||
pluginsList.add(InsulinOrefUltraRapidActingPlugin.getPlugin());
|
||||
pluginsList.add(InsulinOrefFreePeakPlugin.getPlugin());
|
||||
|
@ -156,33 +165,48 @@ public class MainApp extends Application {
|
|||
pluginsList.add(SensitivityAAPSPlugin.getPlugin());
|
||||
pluginsList.add(SensitivityWeightedAveragePlugin.getPlugin());
|
||||
pluginsList.add(SensitivityOref1Plugin.getPlugin());
|
||||
if (Config.PUMPDRIVERS) pluginsList.add(DanaRPlugin.getPlugin());
|
||||
if (Config.PUMPDRIVERS) pluginsList.add(DanaRKoreanPlugin.getPlugin());
|
||||
if (Config.PUMPDRIVERS) pluginsList.add(DanaRv2Plugin.getPlugin());
|
||||
if (Config.PUMPDRIVERS) pluginsList.add(DanaRSPlugin.getPlugin());
|
||||
if (Config.PUMPDRIVERS)
|
||||
pluginsList.add(DanaRPlugin.getPlugin());
|
||||
if (Config.PUMPDRIVERS)
|
||||
pluginsList.add(DanaRKoreanPlugin.getPlugin());
|
||||
if (Config.PUMPDRIVERS)
|
||||
pluginsList.add(DanaRv2Plugin.getPlugin());
|
||||
if (Config.PUMPDRIVERS)
|
||||
pluginsList.add(DanaRSPlugin.getPlugin());
|
||||
pluginsList.add(CareportalPlugin.getPlugin());
|
||||
if (Config.PUMPDRIVERS && engineeringMode)
|
||||
pluginsList.add(InsightPlugin.getPlugin()); // <-- Enable Insight plugin here
|
||||
if (Config.PUMPDRIVERS) pluginsList.add(ComboPlugin.getPlugin());
|
||||
if (Config.MDI) pluginsList.add(MDIPlugin.getPlugin());
|
||||
if (Config.PUMPDRIVERS)
|
||||
pluginsList.add(ComboPlugin.getPlugin());
|
||||
if (Config.MDI)
|
||||
pluginsList.add(MDIPlugin.getPlugin());
|
||||
pluginsList.add(VirtualPumpPlugin.getPlugin());
|
||||
if (Config.APS) pluginsList.add(LoopPlugin.getPlugin());
|
||||
if (Config.APS) pluginsList.add(OpenAPSMAPlugin.getPlugin());
|
||||
if (Config.APS) pluginsList.add(OpenAPSAMAPlugin.getPlugin());
|
||||
if (Config.APS) pluginsList.add(OpenAPSSMBPlugin.getPlugin());
|
||||
if (Config.APS)
|
||||
pluginsList.add(LoopPlugin.getPlugin());
|
||||
if (Config.APS)
|
||||
pluginsList.add(OpenAPSMAPlugin.getPlugin());
|
||||
if (Config.APS)
|
||||
pluginsList.add(OpenAPSAMAPlugin.getPlugin());
|
||||
if (Config.APS)
|
||||
pluginsList.add(OpenAPSSMBPlugin.getPlugin());
|
||||
pluginsList.add(NSProfilePlugin.getPlugin());
|
||||
if (Config.OTHERPROFILES) pluginsList.add(SimpleProfilePlugin.getPlugin());
|
||||
if (Config.OTHERPROFILES) pluginsList.add(LocalProfilePlugin.getPlugin());
|
||||
if (Config.OTHERPROFILES)
|
||||
pluginsList.add(SimpleProfilePlugin.getPlugin());
|
||||
if (Config.OTHERPROFILES)
|
||||
pluginsList.add(LocalProfilePlugin.getPlugin());
|
||||
pluginsList.add(TreatmentsPlugin.getPlugin());
|
||||
if (Config.SAFETY) pluginsList.add(SafetyPlugin.getPlugin());
|
||||
if (Config.APS) pluginsList.add(ObjectivesPlugin.getPlugin());
|
||||
if (Config.SAFETY)
|
||||
pluginsList.add(SafetyPlugin.getPlugin());
|
||||
if (Config.APS)
|
||||
pluginsList.add(ObjectivesPlugin.getPlugin());
|
||||
pluginsList.add(SourceXdripPlugin.getPlugin());
|
||||
pluginsList.add(SourceNSClientPlugin.getPlugin());
|
||||
pluginsList.add(SourceMM640gPlugin.getPlugin());
|
||||
pluginsList.add(SourceGlimpPlugin.getPlugin());
|
||||
pluginsList.add(SourceDexcomG5Plugin.getPlugin());
|
||||
pluginsList.add(SourcePoctechPlugin.getPlugin());
|
||||
if (Config.SMSCOMMUNICATORENABLED) pluginsList.add(SmsCommunicatorPlugin.getPlugin());
|
||||
if (Config.SMSCOMMUNICATORENABLED)
|
||||
pluginsList.add(SmsCommunicatorPlugin.getPlugin());
|
||||
pluginsList.add(FoodPlugin.getPlugin());
|
||||
|
||||
pluginsList.add(WearPlugin.initPlugin(this));
|
||||
|
@ -208,6 +232,7 @@ public class MainApp extends Application {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private void registerLocalBroadcastReceiver() {
|
||||
lbm = LocalBroadcastManager.getInstance(this);
|
||||
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_TREATMENT));
|
||||
|
@ -223,16 +248,16 @@ public class MainApp extends Application {
|
|||
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_DEVICESTATUS));
|
||||
lbm.registerReceiver(dataReceiver, new IntentFilter(Intents.ACTION_NEW_CAL));
|
||||
|
||||
//register alarms
|
||||
// register alarms
|
||||
lbm.registerReceiver(alarmReciever, new IntentFilter(Intents.ACTION_ALARM));
|
||||
lbm.registerReceiver(alarmReciever, new IntentFilter(Intents.ACTION_ANNOUNCEMENT));
|
||||
lbm.registerReceiver(alarmReciever, new IntentFilter(Intents.ACTION_CLEAR_ALARM));
|
||||
lbm.registerReceiver(alarmReciever, new IntentFilter(Intents.ACTION_URGENT_ALARM));
|
||||
|
||||
//register ack alarm
|
||||
// register ack alarm
|
||||
lbm.registerReceiver(ackAlarmReciever, new IntentFilter(Intents.ACTION_ACK_ALARM));
|
||||
|
||||
//register dbaccess
|
||||
// register dbaccess
|
||||
lbm.registerReceiver(dbAccessReciever, new IntentFilter(Intents.ACTION_DATABASE));
|
||||
}
|
||||
|
||||
|
@ -280,11 +305,13 @@ public class MainApp extends Application {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public void stopKeepAliveService() {
|
||||
if (keepAliveReceiver != null)
|
||||
KeepAliveReceiver.cancelAlarm(this);
|
||||
}
|
||||
|
||||
|
||||
public static void subscribe(Object subscriber) {
|
||||
try {
|
||||
bus().register(subscriber);
|
||||
|
@ -293,6 +320,7 @@ public class MainApp extends Application {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public static void unsubscribe(Object subscriber) {
|
||||
try {
|
||||
bus().unregister(subscriber);
|
||||
|
@ -301,34 +329,42 @@ public class MainApp extends Application {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public static Bus bus() {
|
||||
return sBus;
|
||||
}
|
||||
|
||||
|
||||
public static String gs(int id) {
|
||||
return sResources.getString(id);
|
||||
}
|
||||
|
||||
|
||||
public static String gs(int id, Object... args) {
|
||||
return sResources.getString(id, args);
|
||||
}
|
||||
|
||||
|
||||
public static String gq(@PluralsRes int id, int quantity, Object... args) {
|
||||
return sResources.getQuantityString(id, quantity, args);
|
||||
}
|
||||
|
||||
|
||||
public static int gc(int id) {
|
||||
return sResources.getColor(id);
|
||||
}
|
||||
|
||||
|
||||
public static MainApp instance() {
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
|
||||
public static DatabaseHelper getDbHelper() {
|
||||
return sDatabaseHelper;
|
||||
}
|
||||
|
||||
|
||||
public static void closeDbHelper() {
|
||||
if (sDatabaseHelper != null) {
|
||||
sDatabaseHelper.close();
|
||||
|
@ -336,14 +372,17 @@ public class MainApp extends Application {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public static ConstraintChecker getConstraintChecker() {
|
||||
return sConstraintsChecker;
|
||||
}
|
||||
|
||||
|
||||
public static ArrayList<PluginBase> getPluginsList() {
|
||||
return pluginsList;
|
||||
}
|
||||
|
||||
|
||||
public static ArrayList<PluginBase> getSpecificPluginsList(PluginType type) {
|
||||
ArrayList<PluginBase> newList = new ArrayList<>();
|
||||
|
||||
|
@ -358,6 +397,7 @@ public class MainApp extends Application {
|
|||
return newList;
|
||||
}
|
||||
|
||||
|
||||
public static ArrayList<PluginBase> getSpecificPluginsVisibleInList(PluginType type) {
|
||||
ArrayList<PluginBase> newList = new ArrayList<>();
|
||||
|
||||
|
@ -373,6 +413,7 @@ public class MainApp extends Application {
|
|||
return newList;
|
||||
}
|
||||
|
||||
|
||||
public static ArrayList<PluginBase> getSpecificPluginsListByInterface(Class interfaceClass) {
|
||||
ArrayList<PluginBase> newList = new ArrayList<>();
|
||||
|
||||
|
@ -387,6 +428,7 @@ public class MainApp extends Application {
|
|||
return newList;
|
||||
}
|
||||
|
||||
|
||||
public static ArrayList<PluginBase> getSpecificPluginsVisibleInListByInterface(Class interfaceClass, PluginType type) {
|
||||
ArrayList<PluginBase> newList = new ArrayList<>();
|
||||
|
||||
|
@ -402,12 +444,13 @@ public class MainApp extends Application {
|
|||
return newList;
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
public static <T extends PluginBase> T getSpecificPlugin(Class<T> pluginClass) {
|
||||
if (pluginsList != null) {
|
||||
for (PluginBase p : pluginsList) {
|
||||
if (pluginClass.isAssignableFrom(p.getClass()))
|
||||
return (T) p;
|
||||
return (T)p;
|
||||
}
|
||||
} else {
|
||||
log.error("pluginsList=null");
|
||||
|
@ -415,16 +458,19 @@ public class MainApp extends Application {
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isEngineeringModeOrRelease() {
|
||||
if (!Config.APS)
|
||||
return true;
|
||||
return engineeringMode || !devBranch;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isDev() {
|
||||
return devBranch;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onTerminate() {
|
||||
if (L.isEnabled(L.CORE))
|
||||
|
|
|
@ -155,7 +155,7 @@ public class MedtronicFragment extends SubscriberFragment {
|
|||
refreshButton.setEnabled(false);
|
||||
MedtronicPumpPlugin.getPlugin().resetStatusState();
|
||||
|
||||
ConfigBuilderPlugin.getCommandQueue().readStatus("Clicked refresh", new Callback() {
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("Clicked refresh", new Callback() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -295,7 +295,7 @@ public class MedtronicFragment extends SubscriberFragment {
|
|||
}
|
||||
|
||||
if (queueView != null) {
|
||||
Spanned status = ConfigBuilderPlugin.getCommandQueue().spannedStatus();
|
||||
Spanned status = ConfigBuilderPlugin.getPlugin().getCommandQueue().spannedStatus();
|
||||
if (status.toString().equals("")) {
|
||||
queueView.setVisibility(View.GONE);
|
||||
} else {
|
||||
|
@ -430,7 +430,7 @@ public class MedtronicFragment extends SubscriberFragment {
|
|||
+ MainApp.gs(R.string.pump_basebasalrate, plugin.getBaseBasalRate()));
|
||||
|
||||
// FIXME temp basal - check - maybe set as combo ??
|
||||
if (ConfigBuilderPlugin.getActivePump().isFakingTempsByExtendedBoluses()) {
|
||||
if (ConfigBuilderPlugin.getPlugin().getActivePump().isFakingTempsByExtendedBoluses()) {
|
||||
if (TreatmentsPlugin.getPlugin().isInHistoryRealTempBasalInProgress()) {
|
||||
tempBasalView.setText(TreatmentsPlugin.getPlugin()
|
||||
.getRealTempBasalFromHistory(System.currentTimeMillis()).toStringFull());
|
||||
|
|
|
@ -183,7 +183,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
|||
SystemClock.sleep(60000);
|
||||
|
||||
if (doWeHaveAnyStatusNeededRefereshing()) {
|
||||
ConfigBuilderPlugin.getCommandQueue().readStatus("Manual Status Refresh", null);
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("Manual Status Refresh", null);
|
||||
}
|
||||
|
||||
} while (serviceRunning);
|
||||
|
|
|
@ -5,8 +5,6 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
|
||||
import info.nightscout.androidaps.plugins.PumpMedtronic.defs.MedtronicDeviceType;
|
||||
import info.nightscout.androidaps.plugins.PumpMedtronic.util.MedtronicUtil;
|
||||
|
||||
|
@ -290,7 +288,7 @@ public enum PumpHistoryEntryType // implements CodeEnum
|
|||
|
||||
|
||||
void addSpecialRuleHead(SpecialRule rule) {
|
||||
if (CollectionUtils.isEmpty(specialRulesHead)) {
|
||||
if (isEmpty(specialRulesHead)) {
|
||||
specialRulesHead = new ArrayList<SpecialRule>();
|
||||
}
|
||||
|
||||
|
@ -300,7 +298,7 @@ public enum PumpHistoryEntryType // implements CodeEnum
|
|||
|
||||
|
||||
void addSpecialRuleBody(SpecialRule rule) {
|
||||
if (CollectionUtils.isEmpty(specialRulesBody)) {
|
||||
if (isEmpty(specialRulesBody)) {
|
||||
specialRulesBody = new ArrayList<SpecialRule>();
|
||||
}
|
||||
|
||||
|
@ -321,7 +319,7 @@ public enum PumpHistoryEntryType // implements CodeEnum
|
|||
|
||||
public int getHeadLength() {
|
||||
if (hasSpecialRules) {
|
||||
if (CollectionUtils.isNotEmpty(specialRulesHead)) {
|
||||
if (isNotEmpty(specialRulesHead)) {
|
||||
return determineSizeByRule(headLength, specialRulesHead);
|
||||
} else {
|
||||
return headLength;
|
||||
|
@ -339,7 +337,7 @@ public enum PumpHistoryEntryType // implements CodeEnum
|
|||
|
||||
public int getBodyLength() {
|
||||
if (hasSpecialRules) {
|
||||
if (CollectionUtils.isNotEmpty(specialRulesBody)) {
|
||||
if (isNotEmpty(specialRulesBody)) {
|
||||
return determineSizeByRule(bodyLength, specialRulesBody);
|
||||
} else {
|
||||
return bodyLength;
|
||||
|
@ -350,6 +348,16 @@ public enum PumpHistoryEntryType // implements CodeEnum
|
|||
}
|
||||
|
||||
|
||||
private boolean isNotEmpty(List list) {
|
||||
return list != null && !list.isEmpty();
|
||||
}
|
||||
|
||||
|
||||
private boolean isEmpty(List list) {
|
||||
return list == null || list.isEmpty();
|
||||
}
|
||||
|
||||
|
||||
// byte[] dh = { 2, 3 };
|
||||
|
||||
private int determineSizeByRule(int defaultValue, List<SpecialRule> rules) {
|
||||
|
|
Loading…
Reference in a new issue