Merge branch 'wip' into dev
This commit is contained in:
commit
6e69b25d8a
104 changed files with 1912 additions and 3401 deletions
|
@ -63,7 +63,7 @@ android {
|
|||
targetSdkVersion 23
|
||||
multiDexEnabled true
|
||||
versionCode 1500
|
||||
version "1.60b-dev"
|
||||
version "1.60c-dev"
|
||||
buildConfigField "String", "VERSION", '"' + version + '"'
|
||||
buildConfigField "String", "BUILDVERSION", generateGitBuild()
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package info.nightscout.androidaps;
|
||||
|
||||
import info.nightscout.utils.T;
|
||||
|
||||
/**
|
||||
* Created by mike on 07.06.2016.
|
||||
*/
|
||||
|
@ -61,4 +63,7 @@ public class Constants {
|
|||
// Pump
|
||||
public static final int PUMP_MAX_CONNECTION_TIME_IN_SECONDS = 120 - 1;
|
||||
public static final int MIN_WATCHDOG_INTERVAL_IN_SECONDS = 12 * 60;
|
||||
|
||||
//SMS Communicator
|
||||
public static final long SMS_CONFIRM_TIMEOUT = T.mins(5).msecs();
|
||||
}
|
||||
|
|
|
@ -27,8 +27,9 @@ import ch.qos.logback.classic.LoggerContext;
|
|||
import info.nightscout.androidaps.Services.Intents;
|
||||
import info.nightscout.androidaps.data.ConstraintChecker;
|
||||
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.Actions.ActionsFragment;
|
||||
import info.nightscout.androidaps.plugins.Careportal.CareportalPlugin;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
|
@ -66,11 +67,11 @@ import info.nightscout.androidaps.plugins.SensitivityAAPS.SensitivityAAPSPlugin;
|
|||
import info.nightscout.androidaps.plugins.SensitivityOref0.SensitivityOref0Plugin;
|
||||
import info.nightscout.androidaps.plugins.SensitivityWeightedAverage.SensitivityWeightedAveragePlugin;
|
||||
import info.nightscout.androidaps.plugins.SmsCommunicator.SmsCommunicatorPlugin;
|
||||
import info.nightscout.androidaps.plugins.SourceDexcomG5.SourceDexcomG5Plugin;
|
||||
import info.nightscout.androidaps.plugins.SourceGlimp.SourceGlimpPlugin;
|
||||
import info.nightscout.androidaps.plugins.SourceMM640g.SourceMM640gPlugin;
|
||||
import info.nightscout.androidaps.plugins.SourceNSClient.SourceNSClientPlugin;
|
||||
import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripPlugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceDexcomG5Plugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceGlimpPlugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceMM640gPlugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceNSClientPlugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceXdripPlugin;
|
||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||
import info.nightscout.androidaps.plugins.Wear.WearPlugin;
|
||||
import info.nightscout.androidaps.plugins.XDripStatusline.StatuslinePlugin;
|
||||
|
@ -110,6 +111,7 @@ public class MainApp extends Application {
|
|||
sInstance = this;
|
||||
sResources = getResources();
|
||||
sConstraintsChecker = new ConstraintChecker(this);
|
||||
sDatabaseHelper = OpenHelperManager.getHelper(sInstance, DatabaseHelper.class);
|
||||
|
||||
try {
|
||||
if (FabricPrivacy.fabricEnabled()) {
|
||||
|
@ -127,7 +129,7 @@ public class MainApp extends Application {
|
|||
log.info("BuildVersion: " + BuildConfig.BUILDVERSION);
|
||||
|
||||
String extFilesDir = this.getLogDirectory();
|
||||
File engineeringModeSemaphore = new File(extFilesDir,"engineering_mode");
|
||||
File engineeringModeSemaphore = new File(extFilesDir, "engineering_mode");
|
||||
|
||||
engineeringMode = engineeringModeSemaphore.exists() && engineeringModeSemaphore.isFile();
|
||||
devBranch = BuildConfig.VERSION.contains("dev");
|
||||
|
@ -155,8 +157,10 @@ public class MainApp extends Application {
|
|||
if (Config.HWPUMPS) pluginsList.add(DanaRv2Plugin.getPlugin());
|
||||
if (Config.HWPUMPS) pluginsList.add(DanaRSPlugin.getPlugin());
|
||||
pluginsList.add(CareportalPlugin.getPlugin());
|
||||
if (Config.HWPUMPS && engineeringMode) pluginsList.add(InsightPlugin.getPlugin()); // <-- Enable Insight plugin here
|
||||
if (Config.HWPUMPS && engineeringMode) pluginsList.add(ComboPlugin.getPlugin()); // <-- Enable Combo plugin here
|
||||
if (Config.HWPUMPS && engineeringMode)
|
||||
pluginsList.add(InsightPlugin.getPlugin()); // <-- Enable Insight plugin here
|
||||
if (Config.HWPUMPS && engineeringMode)
|
||||
pluginsList.add(ComboPlugin.getPlugin()); // <-- Enable Combo plugin here
|
||||
if (Config.MDI) pluginsList.add(MDIPlugin.getPlugin());
|
||||
if (Config.VIRTUALPUMP) pluginsList.add(VirtualPumpPlugin.getPlugin());
|
||||
if (Config.APS) pluginsList.add(LoopPlugin.getPlugin());
|
||||
|
@ -204,14 +208,14 @@ public class MainApp extends Application {
|
|||
else
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("AppStart-OpenLoop"));
|
||||
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
if (pump != null) {
|
||||
new Thread(() -> {
|
||||
SystemClock.sleep(5000);
|
||||
ConfigBuilderPlugin.getCommandQueue().readStatus("Initialization", null);
|
||||
startKeepAliveService();
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
if (!isEngineeringModeOrRelease()) {
|
||||
Notification n = new Notification(Notification.TOAST_ALARM, gs(R.string.closed_loop_disabled_on_dev_branch), Notification.NORMAL);
|
||||
|
@ -303,7 +307,7 @@ public class MainApp extends Application {
|
|||
return pluginsList;
|
||||
}
|
||||
|
||||
public static ArrayList<PluginBase> getSpecificPluginsList(int type) {
|
||||
public static ArrayList<PluginBase> getSpecificPluginsList(PluginType type) {
|
||||
ArrayList<PluginBase> newList = new ArrayList<>();
|
||||
|
||||
if (pluginsList != null) {
|
||||
|
@ -317,11 +321,12 @@ public class MainApp extends Application {
|
|||
return newList;
|
||||
}
|
||||
|
||||
/*
|
||||
@Nullable
|
||||
public static InsulinInterface getInsulinIterfaceById(int id) {
|
||||
if (pluginsList != null) {
|
||||
for (PluginBase p : pluginsList) {
|
||||
if (p.getType() == PluginBase.INSULIN && ((InsulinInterface) p).getId() == id)
|
||||
if (p.getType() == PluginType.INSULIN && ((InsulinInterface) p).getId() == id)
|
||||
return (InsulinInterface) p;
|
||||
}
|
||||
} else {
|
||||
|
@ -329,8 +334,9 @@ public class MainApp extends Application {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
*/
|
||||
|
||||
public static ArrayList<PluginBase> getSpecificPluginsVisibleInList(int type) {
|
||||
public static ArrayList<PluginBase> getSpecificPluginsVisibleInList(PluginType type) {
|
||||
ArrayList<PluginBase> newList = new ArrayList<>();
|
||||
|
||||
if (pluginsList != null) {
|
||||
|
@ -359,7 +365,7 @@ public class MainApp extends Application {
|
|||
return newList;
|
||||
}
|
||||
|
||||
public static ArrayList<PluginBase> getSpecificPluginsVisibleInListByInterface(Class interfaceClass, int type) {
|
||||
public static ArrayList<PluginBase> getSpecificPluginsVisibleInListByInterface(Class interfaceClass, PluginType type) {
|
||||
ArrayList<PluginBase> newList = new ArrayList<>();
|
||||
|
||||
if (pluginsList != null) {
|
||||
|
|
|
@ -14,6 +14,7 @@ import android.text.TextUtils;
|
|||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||
import info.nightscout.androidaps.events.EventRefreshGui;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.plugins.Careportal.CareportalPlugin;
|
||||
import info.nightscout.androidaps.plugins.ConstraintsSafety.SafetyPlugin;
|
||||
import info.nightscout.androidaps.plugins.Insulin.InsulinOrefFreePeakPlugin;
|
||||
|
@ -31,7 +32,7 @@ import info.nightscout.androidaps.plugins.SensitivityAAPS.SensitivityAAPSPlugin;
|
|||
import info.nightscout.androidaps.plugins.SensitivityOref0.SensitivityOref0Plugin;
|
||||
import info.nightscout.androidaps.plugins.SensitivityWeightedAverage.SensitivityWeightedAveragePlugin;
|
||||
import info.nightscout.androidaps.plugins.SmsCommunicator.SmsCommunicatorPlugin;
|
||||
import info.nightscout.androidaps.plugins.SourceDexcomG5.SourceDexcomG5Plugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceDexcomG5Plugin;
|
||||
import info.nightscout.androidaps.plugins.Wear.WearPlugin;
|
||||
import info.nightscout.androidaps.plugins.XDripStatusline.StatuslinePlugin;
|
||||
import info.nightscout.utils.LocaleHelper;
|
||||
|
@ -111,7 +112,7 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
|
|||
id = args.getInt("id");
|
||||
}
|
||||
|
||||
void addPreferencesFromResourceIfEnabled(PluginBase p, int type) {
|
||||
void addPreferencesFromResourceIfEnabled(PluginBase p, PluginType type) {
|
||||
if (p.isEnabled(type) && p.getPreferencesId() != -1)
|
||||
addPreferencesFromResource(p.getPreferencesId());
|
||||
}
|
||||
|
@ -139,50 +140,50 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
|
|||
if (!Config.NSCLIENT && !Config.G5UPLOADER) {
|
||||
addPreferencesFromResource(R.xml.pref_quickwizard);
|
||||
}
|
||||
addPreferencesFromResourceIfEnabled(SourceDexcomG5Plugin.getPlugin(), PluginBase.BGSOURCE);
|
||||
addPreferencesFromResourceIfEnabled(CareportalPlugin.getPlugin(), PluginBase.GENERAL);
|
||||
addPreferencesFromResourceIfEnabled(SafetyPlugin.getPlugin(), PluginBase.CONSTRAINTS);
|
||||
addPreferencesFromResourceIfEnabled(SourceDexcomG5Plugin.getPlugin(), PluginType.BGSOURCE);
|
||||
addPreferencesFromResourceIfEnabled(CareportalPlugin.getPlugin(), PluginType.GENERAL);
|
||||
addPreferencesFromResourceIfEnabled(SafetyPlugin.getPlugin(), PluginType.CONSTRAINTS);
|
||||
if (Config.APS) {
|
||||
addPreferencesFromResourceIfEnabled(LoopPlugin.getPlugin(), PluginBase.LOOP);
|
||||
addPreferencesFromResourceIfEnabled(OpenAPSMAPlugin.getPlugin(), PluginBase.APS);
|
||||
addPreferencesFromResourceIfEnabled(OpenAPSAMAPlugin.getPlugin(), PluginBase.APS);
|
||||
addPreferencesFromResourceIfEnabled(OpenAPSSMBPlugin.getPlugin(), PluginBase.APS);
|
||||
addPreferencesFromResourceIfEnabled(LoopPlugin.getPlugin(), PluginType.LOOP);
|
||||
addPreferencesFromResourceIfEnabled(OpenAPSMAPlugin.getPlugin(), PluginType.APS);
|
||||
addPreferencesFromResourceIfEnabled(OpenAPSAMAPlugin.getPlugin(), PluginType.APS);
|
||||
addPreferencesFromResourceIfEnabled(OpenAPSSMBPlugin.getPlugin(), PluginType.APS);
|
||||
}
|
||||
|
||||
addPreferencesFromResourceIfEnabled(SensitivityAAPSPlugin.getPlugin(), PluginBase.SENSITIVITY);
|
||||
addPreferencesFromResourceIfEnabled(SensitivityWeightedAveragePlugin.getPlugin(), PluginBase.SENSITIVITY);
|
||||
addPreferencesFromResourceIfEnabled(SensitivityOref0Plugin.getPlugin(), PluginBase.SENSITIVITY);
|
||||
addPreferencesFromResourceIfEnabled(SensitivityAAPSPlugin.getPlugin(), PluginType.SENSITIVITY);
|
||||
addPreferencesFromResourceIfEnabled(SensitivityWeightedAveragePlugin.getPlugin(), PluginType.SENSITIVITY);
|
||||
addPreferencesFromResourceIfEnabled(SensitivityOref0Plugin.getPlugin(), PluginType.SENSITIVITY);
|
||||
|
||||
if (Config.HWPUMPS) {
|
||||
addPreferencesFromResourceIfEnabled(DanaRPlugin.getPlugin(), PluginBase.PUMP);
|
||||
addPreferencesFromResourceIfEnabled(DanaRKoreanPlugin.getPlugin(), PluginBase.PUMP);
|
||||
addPreferencesFromResourceIfEnabled(DanaRv2Plugin.getPlugin(), PluginBase.PUMP);
|
||||
addPreferencesFromResourceIfEnabled(DanaRSPlugin.getPlugin(), PluginBase.PUMP);
|
||||
addPreferencesFromResourceIfEnabled(DanaRPlugin.getPlugin(), PluginType.PUMP);
|
||||
addPreferencesFromResourceIfEnabled(DanaRKoreanPlugin.getPlugin(), PluginType.PUMP);
|
||||
addPreferencesFromResourceIfEnabled(DanaRv2Plugin.getPlugin(), PluginType.PUMP);
|
||||
addPreferencesFromResourceIfEnabled(DanaRSPlugin.getPlugin(), PluginType.PUMP);
|
||||
|
||||
if (DanaRPlugin.getPlugin().isEnabled(PluginBase.PROFILE)
|
||||
|| DanaRKoreanPlugin.getPlugin().isEnabled(PluginBase.PROFILE)
|
||||
|| DanaRv2Plugin.getPlugin().isEnabled(PluginBase.PROFILE)
|
||||
|| DanaRSPlugin.getPlugin().isEnabled(PluginBase.PROFILE)) {
|
||||
if (DanaRPlugin.getPlugin().isEnabled(PluginType.PROFILE)
|
||||
|| DanaRKoreanPlugin.getPlugin().isEnabled(PluginType.PROFILE)
|
||||
|| DanaRv2Plugin.getPlugin().isEnabled(PluginType.PROFILE)
|
||||
|| DanaRSPlugin.getPlugin().isEnabled(PluginType.PROFILE)) {
|
||||
addPreferencesFromResource(R.xml.pref_danarprofile);
|
||||
}
|
||||
}
|
||||
|
||||
if (!Config.NSCLIENT && !Config.G5UPLOADER) {
|
||||
addPreferencesFromResourceIfEnabled(VirtualPumpPlugin.getPlugin(), PluginBase.PUMP);
|
||||
addPreferencesFromResourceIfEnabled(VirtualPumpPlugin.getPlugin(), PluginType.PUMP);
|
||||
}
|
||||
|
||||
addPreferencesFromResourceIfEnabled(InsulinOrefFreePeakPlugin.getPlugin(), PluginBase.INSULIN);
|
||||
addPreferencesFromResourceIfEnabled(InsulinOrefFreePeakPlugin.getPlugin(), PluginType.INSULIN);
|
||||
|
||||
addPreferencesFromResourceIfEnabled(NSClientPlugin.getPlugin(), PluginBase.GENERAL);
|
||||
addPreferencesFromResourceIfEnabled(SmsCommunicatorPlugin.getPlugin(), PluginBase.GENERAL);
|
||||
addPreferencesFromResourceIfEnabled(NSClientPlugin.getPlugin(), PluginType.GENERAL);
|
||||
addPreferencesFromResourceIfEnabled(SmsCommunicatorPlugin.getPlugin(), PluginType.GENERAL);
|
||||
|
||||
if (!Config.NSCLIENT && !Config.G5UPLOADER) {
|
||||
addPreferencesFromResource(R.xml.pref_others);
|
||||
}
|
||||
addPreferencesFromResource(R.xml.pref_advanced);
|
||||
|
||||
addPreferencesFromResourceIfEnabled(WearPlugin.getPlugin(), PluginBase.GENERAL);
|
||||
addPreferencesFromResourceIfEnabled(StatuslinePlugin.getPlugin(), PluginBase.GENERAL);
|
||||
addPreferencesFromResourceIfEnabled(WearPlugin.getPlugin(), PluginType.GENERAL);
|
||||
addPreferencesFromResourceIfEnabled(StatuslinePlugin.getPlugin(), PluginType.GENERAL);
|
||||
}
|
||||
|
||||
initSummary(getPreferenceScreen());
|
||||
|
|
|
@ -33,11 +33,11 @@ import info.nightscout.androidaps.plugins.ProfileNS.NSProfilePlugin;
|
|||
import info.nightscout.androidaps.plugins.ProfileNS.events.EventNSProfileUpdateGUI;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.activities.DanaRNSHistorySync;
|
||||
import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventNewSMS;
|
||||
import info.nightscout.androidaps.plugins.SourceDexcomG5.SourceDexcomG5Plugin;
|
||||
import info.nightscout.androidaps.plugins.SourceGlimp.SourceGlimpPlugin;
|
||||
import info.nightscout.androidaps.plugins.SourceMM640g.SourceMM640gPlugin;
|
||||
import info.nightscout.androidaps.plugins.SourceNSClient.SourceNSClientPlugin;
|
||||
import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripPlugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceDexcomG5Plugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceGlimpPlugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceMM640gPlugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceNSClientPlugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceXdripPlugin;
|
||||
import info.nightscout.androidaps.receivers.DataReceiver;
|
||||
import info.nightscout.utils.BundleLogger;
|
||||
import info.nightscout.utils.NSUpload;
|
||||
|
@ -62,8 +62,13 @@ public class DataService extends IntentService {
|
|||
protected void onHandleIntent(final Intent intent) {
|
||||
if (Config.logFunctionCalls)
|
||||
log.debug("onHandleIntent " + BundleLogger.log(intent.getExtras()));
|
||||
|
||||
if (ConfigBuilderPlugin.getPlugin().getActiveBgSource().getClass().equals(SourceXdripPlugin.class)) {
|
||||
if (ConfigBuilderPlugin.getPlugin().getActiveBgSource() == null) {
|
||||
xDripEnabled = true;
|
||||
nsClientEnabled = false;
|
||||
mm640gEnabled = false;
|
||||
glimpEnabled = false;
|
||||
dexcomG5Enabled = false;
|
||||
} else if (ConfigBuilderPlugin.getPlugin().getActiveBgSource().getClass().equals(SourceXdripPlugin.class)) {
|
||||
xDripEnabled = true;
|
||||
nsClientEnabled = false;
|
||||
mm640gEnabled = false;
|
||||
|
@ -95,7 +100,7 @@ public class DataService extends IntentService {
|
|||
dexcomG5Enabled = true;
|
||||
}
|
||||
|
||||
boolean isNSProfile = MainApp.getConfigBuilder().getActiveProfileInterface().getClass().equals(NSProfilePlugin.class);
|
||||
boolean isNSProfile = MainApp.getConfigBuilder().getActiveProfileInterface() != null && MainApp.getConfigBuilder().getActiveProfileInterface().getClass().equals(NSProfilePlugin.class);
|
||||
|
||||
boolean acceptNSData = !SP.getBoolean(R.string.key_ns_upload_only, false);
|
||||
Bundle bundles = intent.getExtras();
|
||||
|
@ -222,7 +227,7 @@ public class DataService extends IntentService {
|
|||
try {
|
||||
JSONArray jsonArray = new JSONArray(data);
|
||||
log.debug("Received Dexcom Data size:" + jsonArray.length());
|
||||
for(int i = 0; i < jsonArray.length(); i++) {
|
||||
for (int i = 0; i < jsonArray.length(); i++) {
|
||||
JSONObject json = jsonArray.getJSONObject(i);
|
||||
bgReading.value = json.getInt("m_value");
|
||||
bgReading.direction = json.getString("m_trend");
|
||||
|
|
|
@ -8,6 +8,7 @@ import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
|||
import info.nightscout.androidaps.interfaces.Constraint;
|
||||
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
|
||||
/**
|
||||
|
@ -73,7 +74,7 @@ public class ConstraintChecker implements ConstraintsInterface {
|
|||
ArrayList<PluginBase> constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||
for (PluginBase p : constraintsPlugins) {
|
||||
ConstraintsInterface constraint = (ConstraintsInterface) p;
|
||||
if (!p.isEnabled(PluginBase.CONSTRAINTS)) continue;
|
||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
|
||||
constraint.isLoopInvokationAllowed(value);
|
||||
}
|
||||
return value;
|
||||
|
@ -85,7 +86,7 @@ public class ConstraintChecker implements ConstraintsInterface {
|
|||
ArrayList<PluginBase> constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||
for (PluginBase p : constraintsPlugins) {
|
||||
ConstraintsInterface constraint = (ConstraintsInterface) p;
|
||||
if (!p.isEnabled(PluginBase.CONSTRAINTS)) continue;
|
||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
|
||||
constraint.isClosedLoopAllowed(value);
|
||||
}
|
||||
return value;
|
||||
|
@ -97,7 +98,7 @@ public class ConstraintChecker implements ConstraintsInterface {
|
|||
ArrayList<PluginBase> constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||
for (PluginBase p : constraintsPlugins) {
|
||||
ConstraintsInterface constraint = (ConstraintsInterface) p;
|
||||
if (!p.isEnabled(PluginBase.CONSTRAINTS)) continue;
|
||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
|
||||
constraint.isAutosensModeEnabled(value);
|
||||
}
|
||||
return value;
|
||||
|
@ -109,7 +110,7 @@ public class ConstraintChecker implements ConstraintsInterface {
|
|||
ArrayList<PluginBase> constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||
for (PluginBase p : constraintsPlugins) {
|
||||
ConstraintsInterface constrain = (ConstraintsInterface) p;
|
||||
if (!p.isEnabled(PluginBase.CONSTRAINTS)) continue;
|
||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
|
||||
constrain.isAMAModeEnabled(value);
|
||||
}
|
||||
return value;
|
||||
|
@ -121,7 +122,7 @@ public class ConstraintChecker implements ConstraintsInterface {
|
|||
ArrayList<PluginBase> constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||
for (PluginBase p : constraintsPlugins) {
|
||||
ConstraintsInterface constraint = (ConstraintsInterface) p;
|
||||
if (!p.isEnabled(PluginBase.CONSTRAINTS)) continue;
|
||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
|
||||
constraint.isSMBModeEnabled(value);
|
||||
}
|
||||
return value;
|
||||
|
@ -132,7 +133,7 @@ public class ConstraintChecker implements ConstraintsInterface {
|
|||
ArrayList<PluginBase> constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||
for (PluginBase p : constraintsPlugins) {
|
||||
ConstraintsInterface constraint = (ConstraintsInterface) p;
|
||||
if (!p.isEnabled(PluginBase.CONSTRAINTS)) continue;
|
||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
|
||||
constraint.isAdvancedFilteringEnabled(value);
|
||||
}
|
||||
return value;
|
||||
|
@ -143,7 +144,7 @@ public class ConstraintChecker implements ConstraintsInterface {
|
|||
ArrayList<PluginBase> constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||
for (PluginBase p : constraintsPlugins) {
|
||||
ConstraintsInterface constraint = (ConstraintsInterface) p;
|
||||
if (!p.isEnabled(PluginBase.CONSTRAINTS)) continue;
|
||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
|
||||
constraint.applyBasalConstraints(absoluteRate, profile);
|
||||
}
|
||||
return absoluteRate;
|
||||
|
@ -154,7 +155,7 @@ public class ConstraintChecker implements ConstraintsInterface {
|
|||
ArrayList<PluginBase> constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||
for (PluginBase p : constraintsPlugins) {
|
||||
ConstraintsInterface constrain = (ConstraintsInterface) p;
|
||||
if (!p.isEnabled(PluginBase.CONSTRAINTS)) continue;
|
||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
|
||||
constrain.applyBasalPercentConstraints(percentRate, profile);
|
||||
}
|
||||
return percentRate;
|
||||
|
@ -165,7 +166,7 @@ public class ConstraintChecker implements ConstraintsInterface {
|
|||
ArrayList<PluginBase> constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||
for (PluginBase p : constraintsPlugins) {
|
||||
ConstraintsInterface constrain = (ConstraintsInterface) p;
|
||||
if (!p.isEnabled(PluginBase.CONSTRAINTS)) continue;
|
||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
|
||||
constrain.applyBolusConstraints(insulin);
|
||||
}
|
||||
return insulin;
|
||||
|
@ -176,7 +177,7 @@ public class ConstraintChecker implements ConstraintsInterface {
|
|||
ArrayList<PluginBase> constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||
for (PluginBase p : constraintsPlugins) {
|
||||
ConstraintsInterface constrain = (ConstraintsInterface) p;
|
||||
if (!p.isEnabled(PluginBase.CONSTRAINTS)) continue;
|
||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
|
||||
constrain.applyCarbsConstraints(carbs);
|
||||
}
|
||||
return carbs;
|
||||
|
@ -187,7 +188,7 @@ public class ConstraintChecker implements ConstraintsInterface {
|
|||
ArrayList<PluginBase> constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||
for (PluginBase p : constraintsPlugins) {
|
||||
ConstraintsInterface constrain = (ConstraintsInterface) p;
|
||||
if (!p.isEnabled(PluginBase.CONSTRAINTS)) continue;
|
||||
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
|
||||
constrain.applyMaxIOBConstraints(maxIob);
|
||||
}
|
||||
return maxIob;
|
||||
|
|
|
@ -1,34 +1,157 @@
|
|||
package info.nightscout.androidaps.interfaces;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
|
||||
/**
|
||||
* Created by mike on 09.06.2016.
|
||||
*/
|
||||
public interface PluginBase {
|
||||
int GENERAL = 1;
|
||||
int TREATMENT = 2;
|
||||
int SENSITIVITY = 3;
|
||||
int PROFILE = 4;
|
||||
int APS = 5;
|
||||
int PUMP = 6;
|
||||
int CONSTRAINTS = 7;
|
||||
int LOOP = 8;
|
||||
int BGSOURCE = 9;
|
||||
int INSULIN = 10;
|
||||
int LAST = 11; // keep always highest number
|
||||
public abstract class PluginBase {
|
||||
public enum State {
|
||||
NOT_INITIALIZED,
|
||||
ENABLED,
|
||||
DISABLED
|
||||
}
|
||||
|
||||
int getType();
|
||||
String getFragmentClass();
|
||||
State state = State.NOT_INITIALIZED;
|
||||
boolean isFragmentVisible = false;
|
||||
public PluginDescription pluginDescription;
|
||||
|
||||
String getName();
|
||||
String getNameShort();
|
||||
boolean isEnabled(int type);
|
||||
boolean isVisibleInTabs(int type);
|
||||
boolean canBeHidden(int type);
|
||||
boolean hasFragment();
|
||||
boolean showInList(int type);
|
||||
void setPluginEnabled(int type, boolean fragmentEnabled);
|
||||
void setFragmentVisible(int type, boolean fragmentVisible);
|
||||
int getPreferencesId();
|
||||
|
||||
// Specific plugin with more Interfaces
|
||||
protected boolean isProfileInterfaceEnabled = false;
|
||||
|
||||
public PluginBase(PluginDescription pluginDescription) {
|
||||
this.pluginDescription = pluginDescription;
|
||||
}
|
||||
|
||||
// public PluginType getType() {
|
||||
// return mainType;
|
||||
// }
|
||||
|
||||
// public String getFragmentClass() {
|
||||
// return fragmentClass;
|
||||
// }
|
||||
|
||||
public String getName() {
|
||||
if (pluginDescription.pluginName == -1)
|
||||
return "UKNOWN";
|
||||
else
|
||||
return MainApp.gs(pluginDescription.pluginName);
|
||||
}
|
||||
|
||||
public String getNameShort() {
|
||||
if (pluginDescription.shortName == -1)
|
||||
return getName();
|
||||
String name = MainApp.gs(pluginDescription.shortName);
|
||||
if (!name.trim().isEmpty()) //only if translation exists
|
||||
return name;
|
||||
// use long name as fallback
|
||||
return getName();
|
||||
}
|
||||
|
||||
public PluginType getType() {
|
||||
return pluginDescription.mainType;
|
||||
}
|
||||
|
||||
public int getPreferencesId() {
|
||||
return pluginDescription.preferencesId;
|
||||
}
|
||||
|
||||
public int getAdvancedPreferencesId() {
|
||||
return pluginDescription.advancedPreferencesId;
|
||||
}
|
||||
|
||||
public boolean isEnabled(PluginType type) {
|
||||
if (pluginDescription.alwaysEnabled && type == pluginDescription.mainType)
|
||||
return true;
|
||||
if (pluginDescription.mainType == PluginType.CONSTRAINTS && type == PluginType.CONSTRAINTS)
|
||||
return true;
|
||||
if (type == pluginDescription.mainType)
|
||||
return state == State.ENABLED && specialEnableCondition();
|
||||
if (type == PluginType.CONSTRAINTS && pluginDescription.mainType == PluginType.PUMP && isEnabled(PluginType.PUMP))
|
||||
return true;
|
||||
if (type == PluginType.PROFILE && pluginDescription.mainType == PluginType.PUMP)
|
||||
return isProfileInterfaceEnabled;
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canBeHidden(PluginType type) {
|
||||
return pluginDescription.canBeHidden;
|
||||
}
|
||||
|
||||
public boolean hasFragment() {
|
||||
return pluginDescription.fragmentClass != null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* So far plugin can have it's main type + ConstraintInterface + ProfileInterface
|
||||
* ConstraintInterface is enabled if main plugin is enabled
|
||||
* ProfileInterface can be enabled only if main iterface is enable
|
||||
*/
|
||||
|
||||
public void setPluginEnabled(PluginType type, boolean newState) {
|
||||
if (type == pluginDescription.mainType) {
|
||||
if (newState == true) { // enabling plugin
|
||||
if (state != State.ENABLED) {
|
||||
onStateChange(type, state, State.ENABLED);
|
||||
state = State.ENABLED;
|
||||
onStart();
|
||||
}
|
||||
} else { // disabling plugin
|
||||
if (state == State.ENABLED) {
|
||||
onStateChange(type, state, State.ENABLED);
|
||||
state = State.DISABLED;
|
||||
onStop();
|
||||
}
|
||||
}
|
||||
} else if (type == PluginType.PROFILE) {
|
||||
isProfileInterfaceEnabled = newState;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setFragmentVisible(PluginType type, boolean fragmentVisible) {
|
||||
if (type == pluginDescription.mainType) {
|
||||
isFragmentVisible = fragmentVisible && specialEnableCondition();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isFragmentVisible() {
|
||||
if (pluginDescription.alwayVisible)
|
||||
return true;
|
||||
if (pluginDescription.neverVisible)
|
||||
return false;
|
||||
return isFragmentVisible;
|
||||
}
|
||||
|
||||
public boolean showInList(PluginType type) {
|
||||
if (pluginDescription.mainType == type)
|
||||
return pluginDescription.showInList && specialShowInListCondition();
|
||||
|
||||
if (type == PluginType.PROFILE && pluginDescription.mainType == PluginType.PUMP)
|
||||
return isEnabled(PluginType.PUMP);
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean specialEnableCondition() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean specialShowInListCondition() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void onStart() {
|
||||
}
|
||||
|
||||
protected void onStop() {
|
||||
}
|
||||
|
||||
protected void onStateChange(PluginType type, State oldState, State newState) {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
package info.nightscout.androidaps.interfaces;
|
||||
|
||||
public class PluginDescription {
|
||||
PluginType mainType = PluginType.GENERAL;
|
||||
String fragmentClass = null;
|
||||
boolean canBeHidden = true;
|
||||
public boolean alwayVisible = false;
|
||||
public boolean neverVisible = false;
|
||||
public boolean alwaysEnabled = false;
|
||||
boolean showInList = true;
|
||||
int pluginName = -1;
|
||||
int shortName = -1;
|
||||
int preferencesId = -1;
|
||||
int advancedPreferencesId = -1;
|
||||
public boolean enableByDefault = false;
|
||||
public boolean visibleByDefault = false;
|
||||
|
||||
public PluginDescription mainType(PluginType mainType) {
|
||||
this.mainType = mainType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PluginDescription fragmentClass(String fragmentClass) {
|
||||
this.fragmentClass = fragmentClass;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PluginDescription canBeHidden(boolean canBeHidden) {
|
||||
this.canBeHidden = canBeHidden;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PluginDescription alwaysEnabled(boolean alwaysEnabled) {
|
||||
this.alwaysEnabled = alwaysEnabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PluginDescription alwayVisible(boolean alwayVisible) {
|
||||
this.alwayVisible = alwayVisible;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PluginDescription neverVisible(boolean neverVisible) {
|
||||
this.neverVisible = neverVisible;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PluginDescription showInList(boolean showInList) {
|
||||
this.showInList = showInList;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PluginDescription pluginName(int pluginName) {
|
||||
this.pluginName = pluginName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PluginDescription shortName(int shortName) {
|
||||
this.shortName = shortName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PluginDescription preferencesId(int preferencesId) {
|
||||
this.preferencesId = preferencesId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PluginDescription advancedPreferencesId(int advancedPreferencesId) {
|
||||
this.advancedPreferencesId = advancedPreferencesId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PluginDescription enableByDefault(boolean enableByDefault) {
|
||||
this.enableByDefault = enableByDefault;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PluginDescription visibleByDefault(boolean visibleByDefault) {
|
||||
this.visibleByDefault = visibleByDefault;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getFragmentClass() {
|
||||
return fragmentClass;
|
||||
}
|
||||
|
||||
public PluginType getType() {
|
||||
return mainType;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package info.nightscout.androidaps.interfaces;
|
||||
|
||||
public enum PluginType {
|
||||
GENERAL,
|
||||
TREATMENT,
|
||||
SENSITIVITY,
|
||||
PROFILE,
|
||||
APS,
|
||||
PUMP,
|
||||
CONSTRAINTS,
|
||||
LOOP,
|
||||
BGSOURCE,
|
||||
INSULIN
|
||||
}
|
|
@ -1,82 +1,22 @@
|
|||
package info.nightscout.androidaps.plugins.Actions;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.11.2016.
|
||||
*/
|
||||
|
||||
public class ActionsPlugin implements PluginBase {
|
||||
public class ActionsPlugin extends PluginBase {
|
||||
|
||||
private boolean fragmentEnabled = true;
|
||||
private boolean fragmentVisible = true;
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return PluginBase.GENERAL;
|
||||
public ActionsPlugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.GENERAL)
|
||||
.fragmentClass(ActionsFragment.class.getName())
|
||||
.pluginName(R.string.actions)
|
||||
.shortName(R.string.actions_shortname)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return ActionsFragment.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MainApp.sResources.getString(R.string.actions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameShort() {
|
||||
String name = MainApp.sResources.getString(R.string.actions_shortname);
|
||||
if (!name.trim().isEmpty()){
|
||||
//only if translation exists
|
||||
return name;
|
||||
}
|
||||
// use long name as fallback
|
||||
return getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return type == GENERAL && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return type == GENERAL && fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFragment() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInList(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == GENERAL) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == GENERAL) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferencesId() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
package info.nightscout.androidaps.plugins.Careportal;
|
||||
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
|
||||
public class CareportalPlugin implements PluginBase {
|
||||
|
||||
private boolean fragmentEnabled = true;
|
||||
private boolean fragmentVisible = true;
|
||||
public class CareportalPlugin extends PluginBase {
|
||||
|
||||
static CareportalPlugin careportalPlugin;
|
||||
|
||||
|
@ -19,70 +17,18 @@ public class CareportalPlugin implements PluginBase {
|
|||
return careportalPlugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return PluginBase.GENERAL;
|
||||
public CareportalPlugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.GENERAL)
|
||||
.fragmentClass(CareportalFragment.class.getName())
|
||||
.pluginName(R.string.careportal)
|
||||
.shortName(R.string.careportal_shortname)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return CareportalFragment.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MainApp.sResources.getString(R.string.careportal);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameShort() {
|
||||
String name = MainApp.sResources.getString(R.string.careportal_shortname);
|
||||
if (!name.trim().isEmpty()){
|
||||
//only if translation exists
|
||||
return name;
|
||||
}
|
||||
// use long name as fallback
|
||||
return getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return type == GENERAL && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return type == GENERAL && fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFragment() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInList(int type) {
|
||||
public boolean specialShowInListCondition() {
|
||||
return !Config.NSCLIENT && !Config.G5UPLOADER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == GENERAL) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == GENERAL) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferencesId() {
|
||||
return R.xml.pref_careportal;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
|||
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
||||
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.interfaces.SensitivityInterface;
|
||||
|
@ -131,48 +132,48 @@ public class ConfigBuilderFragment extends SubscriberFragment {
|
|||
@Override
|
||||
protected void updateGUI() {
|
||||
|
||||
insulinDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInListByInterface(InsulinInterface.class, PluginBase.INSULIN), PluginBase.INSULIN);
|
||||
insulinDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInListByInterface(InsulinInterface.class, PluginType.INSULIN), PluginType.INSULIN);
|
||||
insulinListView.setAdapter(insulinDataAdapter);
|
||||
setListViewHeightBasedOnChildren(insulinListView);
|
||||
bgsourceDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInListByInterface(BgSourceInterface.class, PluginBase.BGSOURCE), PluginBase.BGSOURCE);
|
||||
bgsourceDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInListByInterface(BgSourceInterface.class, PluginType.BGSOURCE), PluginType.BGSOURCE);
|
||||
bgsourceListView.setAdapter(bgsourceDataAdapter);
|
||||
if (MainApp.getSpecificPluginsVisibleInList(PluginBase.BGSOURCE).size() == 0)
|
||||
if (MainApp.getSpecificPluginsVisibleInList(PluginType.BGSOURCE).size() == 0)
|
||||
bgsourceLabel.setVisibility(View.GONE);
|
||||
setListViewHeightBasedOnChildren(bgsourceListView);
|
||||
pumpDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInList(PluginBase.PUMP), PluginBase.PUMP);
|
||||
pumpDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInList(PluginType.PUMP), PluginType.PUMP);
|
||||
pumpListView.setAdapter(pumpDataAdapter);
|
||||
if (MainApp.getSpecificPluginsVisibleInList(PluginBase.PUMP).size() == 0)
|
||||
if (MainApp.getSpecificPluginsVisibleInList(PluginType.PUMP).size() == 0)
|
||||
pumpLabel.setVisibility(View.GONE);
|
||||
setListViewHeightBasedOnChildren(pumpListView);
|
||||
loopDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInList(PluginBase.LOOP), PluginBase.LOOP);
|
||||
loopDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInList(PluginType.LOOP), PluginType.LOOP);
|
||||
loopListView.setAdapter(loopDataAdapter);
|
||||
setListViewHeightBasedOnChildren(loopListView);
|
||||
if (MainApp.getSpecificPluginsVisibleInList(PluginBase.LOOP).size() == 0)
|
||||
if (MainApp.getSpecificPluginsVisibleInList(PluginType.LOOP).size() == 0)
|
||||
loopLabel.setVisibility(View.GONE);
|
||||
treatmentDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInList(PluginBase.TREATMENT), PluginBase.TREATMENT);
|
||||
treatmentDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInList(PluginType.TREATMENT), PluginType.TREATMENT);
|
||||
treatmentsListView.setAdapter(treatmentDataAdapter);
|
||||
setListViewHeightBasedOnChildren(treatmentsListView);
|
||||
if (MainApp.getSpecificPluginsVisibleInList(PluginBase.TREATMENT).size() == 0)
|
||||
if (MainApp.getSpecificPluginsVisibleInList(PluginType.TREATMENT).size() == 0)
|
||||
treatmentsLabel.setVisibility(View.GONE);
|
||||
profileDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInListByInterface(ProfileInterface.class, PluginBase.PROFILE), PluginBase.PROFILE);
|
||||
profileDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInListByInterface(ProfileInterface.class, PluginType.PROFILE), PluginType.PROFILE);
|
||||
profileListView.setAdapter(profileDataAdapter);
|
||||
if (MainApp.getSpecificPluginsVisibleInList(PluginBase.PROFILE).size() == 0)
|
||||
if (MainApp.getSpecificPluginsVisibleInList(PluginType.PROFILE).size() == 0)
|
||||
profileLabel.setVisibility(View.GONE);
|
||||
setListViewHeightBasedOnChildren(profileListView);
|
||||
apsDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInList(PluginBase.APS), PluginBase.APS);
|
||||
apsDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInList(PluginType.APS), PluginType.APS);
|
||||
apsListView.setAdapter(apsDataAdapter);
|
||||
setListViewHeightBasedOnChildren(apsListView);
|
||||
if (MainApp.getSpecificPluginsVisibleInList(PluginBase.APS).size() == 0)
|
||||
if (MainApp.getSpecificPluginsVisibleInList(PluginType.APS).size() == 0)
|
||||
apsLabel.setVisibility(View.GONE);
|
||||
sensivityDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInListByInterface(SensitivityInterface.class, PluginBase.SENSITIVITY), PluginBase.SENSITIVITY);
|
||||
sensivityDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInListByInterface(SensitivityInterface.class, PluginType.SENSITIVITY), PluginType.SENSITIVITY);
|
||||
sensitivityListView.setAdapter(sensivityDataAdapter);
|
||||
setListViewHeightBasedOnChildren(sensitivityListView);
|
||||
constraintsDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInListByInterface(ConstraintsInterface.class, PluginBase.CONSTRAINTS), PluginBase.CONSTRAINTS);
|
||||
constraintsDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInListByInterface(ConstraintsInterface.class, PluginType.CONSTRAINTS), PluginType.CONSTRAINTS);
|
||||
constraintsListView.setAdapter(constraintsDataAdapter);
|
||||
setListViewHeightBasedOnChildren(constraintsListView);
|
||||
if (MainApp.getSpecificPluginsVisibleInList(PluginBase.CONSTRAINTS).size() == 0)
|
||||
if (MainApp.getSpecificPluginsVisibleInList(PluginType.CONSTRAINTS).size() == 0)
|
||||
constraintsLabel.setVisibility(View.GONE);
|
||||
generalDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInList(PluginBase.GENERAL), PluginBase.GENERAL);
|
||||
generalDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInList(PluginType.GENERAL), PluginType.GENERAL);
|
||||
generalListView.setAdapter(generalDataAdapter);
|
||||
setListViewHeightBasedOnChildren(generalListView);
|
||||
}
|
||||
|
@ -184,10 +185,10 @@ public class ConfigBuilderFragment extends SubscriberFragment {
|
|||
private class PluginCustomAdapter extends ArrayAdapter<PluginBase> {
|
||||
|
||||
private ArrayList<PluginBase> pluginList;
|
||||
final private int type;
|
||||
final private PluginType type;
|
||||
|
||||
PluginCustomAdapter(Context context, int textViewResourceId,
|
||||
ArrayList<PluginBase> pluginList, int type) {
|
||||
ArrayList<PluginBase> pluginList, PluginType type) {
|
||||
super(context, textViewResourceId, pluginList);
|
||||
this.pluginList = new ArrayList<>();
|
||||
this.pluginList.addAll(pluginList);
|
||||
|
@ -230,7 +231,7 @@ public class ConfigBuilderFragment extends SubscriberFragment {
|
|||
plugin1.setPluginEnabled(type, cb.isChecked());
|
||||
plugin1.setFragmentVisible(type, cb.isChecked());
|
||||
onEnabledCategoryChanged(plugin1, type);
|
||||
ConfigBuilderPlugin.getPlugin().storeSettings();
|
||||
ConfigBuilderPlugin.getPlugin().storeSettings("CheckedCheckboxEnabled");
|
||||
MainApp.bus().post(new EventRefreshGui());
|
||||
MainApp.bus().post(new EventConfigBuilderChange());
|
||||
ConfigBuilderPlugin.getPlugin().logPluginStatus();
|
||||
|
@ -241,7 +242,7 @@ public class ConfigBuilderFragment extends SubscriberFragment {
|
|||
CheckBox cb = (CheckBox) v;
|
||||
PluginBase plugin12 = (PluginBase) cb.getTag();
|
||||
plugin12.setFragmentVisible(type, cb.isChecked());
|
||||
ConfigBuilderPlugin.getPlugin().storeSettings();
|
||||
ConfigBuilderPlugin.getPlugin().storeSettings("CheckedCheckboxVisible");
|
||||
MainApp.bus().post(new EventRefreshGui());
|
||||
ConfigBuilderPlugin.getPlugin().logPluginStatus();
|
||||
});
|
||||
|
@ -271,7 +272,7 @@ public class ConfigBuilderFragment extends SubscriberFragment {
|
|||
|
||||
holder.name.setText(plugin.getName());
|
||||
holder.checkboxEnabled.setChecked(plugin.isEnabled(type));
|
||||
holder.checkboxVisible.setChecked(plugin.isVisibleInTabs(type));
|
||||
holder.checkboxVisible.setChecked(plugin.isFragmentVisible());
|
||||
holder.name.setTag(plugin);
|
||||
holder.checkboxEnabled.setTag(plugin);
|
||||
holder.checkboxVisible.setTag(plugin);
|
||||
|
@ -291,19 +292,19 @@ public class ConfigBuilderFragment extends SubscriberFragment {
|
|||
}
|
||||
|
||||
// Hide enabled control and force enabled plugin if there is only one plugin available
|
||||
if (type == PluginBase.INSULIN || type == PluginBase.PUMP || type == PluginBase.TREATMENT || type == PluginBase.PROFILE || type == PluginBase.SENSITIVITY)
|
||||
if (type == PluginType.INSULIN || type == PluginType.PUMP || type == PluginType.SENSITIVITY)
|
||||
if (pluginList.size() < 2) {
|
||||
holder.checkboxEnabled.setEnabled(false);
|
||||
plugin.setPluginEnabled(type, true);
|
||||
ConfigBuilderPlugin.getPlugin().storeSettings();
|
||||
ConfigBuilderPlugin.getPlugin().storeSettings("ForceEnable");
|
||||
}
|
||||
|
||||
// Constraints cannot be disabled
|
||||
if (type == PluginBase.CONSTRAINTS)
|
||||
if (type == PluginType.CONSTRAINTS)
|
||||
holder.checkboxEnabled.setEnabled(false);
|
||||
|
||||
// Hide disabled profiles by default
|
||||
if (type == PluginBase.PROFILE) {
|
||||
if (type == PluginType.PROFILE) {
|
||||
if (!plugin.isEnabled(type)) {
|
||||
holder.checkboxVisible.setEnabled(false);
|
||||
holder.checkboxVisible.setChecked(false);
|
||||
|
@ -313,9 +314,9 @@ public class ConfigBuilderFragment extends SubscriberFragment {
|
|||
}
|
||||
|
||||
// Disable profile control for pump profiles if pump is not enabled
|
||||
if (type == PluginBase.PROFILE) {
|
||||
if (type == PluginType.PROFILE) {
|
||||
if (PumpInterface.class.isAssignableFrom(plugin.getClass())) {
|
||||
if (!plugin.isEnabled(PluginBase.PUMP)) {
|
||||
if (!plugin.isEnabled(PluginType.PUMP)) {
|
||||
holder.checkboxEnabled.setEnabled(false);
|
||||
holder.checkboxEnabled.setChecked(false);
|
||||
}
|
||||
|
@ -332,32 +333,32 @@ public class ConfigBuilderFragment extends SubscriberFragment {
|
|||
|
||||
}
|
||||
|
||||
void onEnabledCategoryChanged(PluginBase changedPlugin, int type) {
|
||||
void onEnabledCategoryChanged(PluginBase changedPlugin, PluginType type) {
|
||||
ArrayList<PluginBase> pluginsInCategory = null;
|
||||
switch (type) {
|
||||
// Multiple selection allowed
|
||||
case PluginBase.GENERAL:
|
||||
case PluginBase.CONSTRAINTS:
|
||||
case PluginBase.LOOP:
|
||||
case GENERAL:
|
||||
case CONSTRAINTS:
|
||||
case LOOP:
|
||||
break;
|
||||
// Single selection allowed
|
||||
case PluginBase.INSULIN:
|
||||
case INSULIN:
|
||||
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(InsulinInterface.class);
|
||||
break;
|
||||
case PluginBase.SENSITIVITY:
|
||||
case SENSITIVITY:
|
||||
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(SensitivityInterface.class);
|
||||
break;
|
||||
case PluginBase.APS:
|
||||
case APS:
|
||||
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(APSInterface.class);
|
||||
break;
|
||||
case PluginBase.PROFILE:
|
||||
case PROFILE:
|
||||
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(ProfileInterface.class);
|
||||
break;
|
||||
case PluginBase.BGSOURCE:
|
||||
case BGSOURCE:
|
||||
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(BgSourceInterface.class);
|
||||
break;
|
||||
case PluginBase.TREATMENT:
|
||||
case PluginBase.PUMP:
|
||||
case TREATMENT:
|
||||
case PUMP:
|
||||
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(PumpInterface.class);
|
||||
break;
|
||||
}
|
||||
|
@ -373,13 +374,13 @@ public class ConfigBuilderFragment extends SubscriberFragment {
|
|||
}
|
||||
}
|
||||
} else { // enable first plugin in list
|
||||
if (type == PluginBase.PUMP)
|
||||
if (type == PluginType.PUMP)
|
||||
VirtualPumpPlugin.getPlugin().setPluginEnabled(type, true);
|
||||
else if (type == PluginBase.INSULIN)
|
||||
else if (type == PluginType.INSULIN)
|
||||
InsulinFastactingPlugin.getPlugin().setPluginEnabled(type, true);
|
||||
else if (type == PluginBase.SENSITIVITY)
|
||||
else if (type == PluginType.SENSITIVITY)
|
||||
SensitivityOref0Plugin.getPlugin().setPluginEnabled(type, true);
|
||||
else if (type == PluginBase.PROFILE)
|
||||
else if (type == PluginType.PROFILE)
|
||||
NSProfilePlugin.getPlugin().setPluginEnabled(type, true);
|
||||
else
|
||||
pluginsInCategory.get(0).setPluginEnabled(type, true);
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package info.nightscout.androidaps.plugins.ConfigBuilder;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.crashlytics.android.answers.CustomEvent;
|
||||
|
@ -42,27 +40,31 @@ import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
|||
import info.nightscout.androidaps.interfaces.Constraint;
|
||||
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.interfaces.SensitivityInterface;
|
||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||
import info.nightscout.androidaps.plugins.Insulin.InsulinOrefRapidActingPlugin;
|
||||
import info.nightscout.androidaps.plugins.Loop.APSResult;
|
||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
||||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
|
||||
import info.nightscout.androidaps.plugins.SensitivityOref0.SensitivityOref0Plugin;
|
||||
import info.nightscout.androidaps.queue.Callback;
|
||||
import info.nightscout.androidaps.queue.CommandQueue;
|
||||
import info.nightscout.androidaps.queue.commands.Command;
|
||||
import info.nightscout.utils.FabricPrivacy;
|
||||
import info.nightscout.utils.NSUpload;
|
||||
import info.nightscout.utils.SP;
|
||||
import info.nightscout.utils.ToastUtils;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class ConfigBuilderPlugin implements PluginBase, TreatmentsInterface {
|
||||
public class ConfigBuilderPlugin extends PluginBase implements TreatmentsInterface {
|
||||
private static Logger log = LoggerFactory.getLogger(ConfigBuilderPlugin.class);
|
||||
|
||||
private static ConfigBuilderPlugin configBuilderPlugin;
|
||||
|
@ -92,122 +94,166 @@ public class ConfigBuilderPlugin implements PluginBase, TreatmentsInterface {
|
|||
private static CommandQueue commandQueue = new CommandQueue();
|
||||
|
||||
public ConfigBuilderPlugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.GENERAL)
|
||||
.fragmentClass(ConfigBuilderFragment.class.getName())
|
||||
.showInList(false)
|
||||
.alwaysEnabled(true)
|
||||
.alwayVisible(true)
|
||||
.pluginName(R.string.configbuilder)
|
||||
.shortName(R.string.configbuilder_shortname)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
MainApp.bus().register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return PluginBase.GENERAL;
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
MainApp.bus().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return ConfigBuilderFragment.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MainApp.instance().getString(R.string.configbuilder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameShort() {
|
||||
String name = MainApp.sResources.getString(R.string.configbuilder_shortname);
|
||||
if (!name.trim().isEmpty()) {
|
||||
//only if translation exists
|
||||
return name;
|
||||
}
|
||||
// use long name as fallback
|
||||
return getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return type == GENERAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return type == GENERAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFragment() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInList(int type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean fragmentEnabled) {
|
||||
// Always enabled
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
// Always visible
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferencesId() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
pluginList = MainApp.getPluginsList();
|
||||
upgradeSettings();
|
||||
loadSettings();
|
||||
MainApp.bus().post(new EventAppInitialized());
|
||||
}
|
||||
|
||||
public void storeSettings() {
|
||||
public void storeSettings(String from) {
|
||||
if (pluginList != null) {
|
||||
if (Config.logPrefsChange)
|
||||
log.debug("Storing settings");
|
||||
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
||||
SharedPreferences.Editor editor = settings.edit();
|
||||
log.debug("Storing settings from: " + from);
|
||||
|
||||
for (int type = 1; type < PluginBase.LAST; type++) {
|
||||
for (PluginBase p : pluginList) {
|
||||
String settingEnabled = "ConfigBuilder_" + type + "_" + p.getClass().getSimpleName() + "_Enabled";
|
||||
String settingVisible = "ConfigBuilder_" + type + "_" + p.getClass().getSimpleName() + "_Visible";
|
||||
editor.putBoolean(settingEnabled, p.isEnabled(type));
|
||||
editor.putBoolean(settingVisible, p.isVisibleInTabs(type));
|
||||
PluginType type = p.getType();
|
||||
if (p.pluginDescription.alwaysEnabled && p.pluginDescription.alwayVisible)
|
||||
continue;
|
||||
if (p.pluginDescription.alwaysEnabled && p.pluginDescription.neverVisible)
|
||||
continue;
|
||||
savePref(p, type, true);
|
||||
if (type == PluginType.PUMP) {
|
||||
if (p instanceof ProfileInterface) { // Store state of optional Profile interface
|
||||
savePref(p, PluginType.PROFILE, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
editor.apply();
|
||||
verifySelectionInCategories();
|
||||
}
|
||||
}
|
||||
|
||||
private void savePref(PluginBase p, PluginType type, boolean storeVisible) {
|
||||
String settingEnabled = "ConfigBuilder_" + type.name() + "_" + p.getClass().getSimpleName() + "_Enabled";
|
||||
SP.putBoolean(settingEnabled, p.isEnabled(type));
|
||||
log.debug("Storing: " + settingEnabled + ":" + p.isEnabled(type));
|
||||
if (storeVisible) {
|
||||
String settingVisible = "ConfigBuilder_" + type.name() + "_" + p.getClass().getSimpleName() + "_Visible";
|
||||
SP.putBoolean(settingVisible, p.isFragmentVisible());
|
||||
log.debug("Storing: " + settingVisible + ":" + p.isFragmentVisible());
|
||||
}
|
||||
}
|
||||
|
||||
private void loadSettings() {
|
||||
if (Config.logPrefsChange)
|
||||
log.debug("Loading stored settings");
|
||||
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
||||
for (int type = 1; type < PluginBase.LAST; type++) {
|
||||
for (PluginBase p : pluginList) {
|
||||
try {
|
||||
String settingEnabled = "ConfigBuilder_" + type + "_" + p.getClass().getSimpleName() + "_Enabled";
|
||||
String settingVisible = "ConfigBuilder_" + type + "_" + p.getClass().getSimpleName() + "_Visible";
|
||||
if (SP.contains(settingEnabled))
|
||||
p.setPluginEnabled(type, SP.getBoolean(settingEnabled, true));
|
||||
if (SP.contains(settingVisible))
|
||||
p.setFragmentVisible(type, SP.getBoolean(settingVisible, true) && SP.getBoolean(settingEnabled, true));
|
||||
} catch (Exception e) {
|
||||
log.error("Unhandled exception", e);
|
||||
PluginType type = p.getType();
|
||||
loadPref(p, type, true);
|
||||
if (p.getType() == PluginType.PUMP) {
|
||||
if (p instanceof ProfileInterface) {
|
||||
loadPref(p, PluginType.PROFILE, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
verifySelectionInCategories();
|
||||
}
|
||||
|
||||
private void loadPref(PluginBase p, PluginType type, boolean loadVisible) {
|
||||
String settingEnabled = "ConfigBuilder_" + type.name() + "_" + p.getClass().getSimpleName() + "_Enabled";
|
||||
if (SP.contains(settingEnabled))
|
||||
p.setPluginEnabled(type, SP.getBoolean(settingEnabled, false));
|
||||
else if (p.getType() == type && p.pluginDescription.enableByDefault) {
|
||||
p.setPluginEnabled(type, true);
|
||||
}
|
||||
log.debug("Loaded: " + settingEnabled + ":" + p.isEnabled(type));
|
||||
if (loadVisible) {
|
||||
String settingVisible = "ConfigBuilder_" + type.name() + "_" + p.getClass().getSimpleName() + "_Visible";
|
||||
if (SP.contains(settingVisible))
|
||||
p.setFragmentVisible(type, SP.getBoolean(settingVisible, false) && SP.getBoolean(settingEnabled, false));
|
||||
else if (p.getType() == type && p.pluginDescription.visibleByDefault) {
|
||||
p.setFragmentVisible(type, true);
|
||||
}
|
||||
log.debug("Loaded: " + settingVisible + ":" + p.isFragmentVisible());
|
||||
}
|
||||
}
|
||||
|
||||
// Detect settings prior 1.60
|
||||
private void upgradeSettings() {
|
||||
if (!SP.contains("ConfigBuilder_1_NSProfilePlugin_Enabled"))
|
||||
return;
|
||||
if (Config.logPrefsChange)
|
||||
log.debug("Upgrading stored settings");
|
||||
for (PluginBase p : pluginList) {
|
||||
log.debug("Processing " + p.getName());
|
||||
for (int type = 1; type < 11; type++) {
|
||||
PluginType newType;
|
||||
switch (type) {
|
||||
case 1:
|
||||
newType = PluginType.GENERAL;
|
||||
break;
|
||||
case 2:
|
||||
newType = PluginType.TREATMENT;
|
||||
break;
|
||||
case 3:
|
||||
newType = PluginType.SENSITIVITY;
|
||||
break;
|
||||
case 4:
|
||||
newType = PluginType.PROFILE;
|
||||
break;
|
||||
case 5:
|
||||
newType = PluginType.APS;
|
||||
break;
|
||||
case 6:
|
||||
newType = PluginType.PUMP;
|
||||
break;
|
||||
case 7:
|
||||
newType = PluginType.CONSTRAINTS;
|
||||
break;
|
||||
case 8:
|
||||
newType = PluginType.LOOP;
|
||||
break;
|
||||
case 9:
|
||||
newType = PluginType.BGSOURCE;
|
||||
break;
|
||||
case 10:
|
||||
newType = PluginType.INSULIN;
|
||||
break;
|
||||
default:
|
||||
newType = PluginType.GENERAL;
|
||||
break;
|
||||
}
|
||||
String settingEnabled = "ConfigBuilder_" + type + "_" + p.getClass().getSimpleName() + "_Enabled";
|
||||
String settingVisible = "ConfigBuilder_" + type + "_" + p.getClass().getSimpleName() + "_Visible";
|
||||
if (SP.contains(settingEnabled))
|
||||
p.setPluginEnabled(newType, SP.getBoolean(settingEnabled, false));
|
||||
if (SP.contains(settingVisible))
|
||||
p.setFragmentVisible(newType, SP.getBoolean(settingVisible, false) && SP.getBoolean(settingEnabled, false));
|
||||
SP.remove(settingEnabled);
|
||||
SP.remove(settingVisible);
|
||||
if (newType == p.getType()) {
|
||||
savePref(p, newType, true);
|
||||
} else if (p.getType() == PluginType.PUMP && p instanceof ProfileInterface) {
|
||||
savePref(p, PluginType.PROFILE, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static CommandQueue getCommandQueue() {
|
||||
return commandQueue;
|
||||
}
|
||||
|
@ -243,16 +289,16 @@ public class ConfigBuilderPlugin implements PluginBase, TreatmentsInterface {
|
|||
void logPluginStatus() {
|
||||
for (PluginBase p : pluginList) {
|
||||
log.debug(p.getName() + ":" +
|
||||
(p.isEnabled(1) ? " GENERAL" : "") +
|
||||
(p.isEnabled(2) ? " TREATMENT" : "") +
|
||||
(p.isEnabled(3) ? " SENSITIVITY" : "") +
|
||||
(p.isEnabled(4) ? " PROFILE" : "") +
|
||||
(p.isEnabled(5) ? " APS" : "") +
|
||||
(p.isEnabled(6) ? " PUMP" : "") +
|
||||
(p.isEnabled(7) ? " CONSTRAINTS" : "") +
|
||||
(p.isEnabled(8) ? " LOOP" : "") +
|
||||
(p.isEnabled(9) ? " BGSOURCE" : "") +
|
||||
(p.isEnabled(10) ? " INSULIN" : "")
|
||||
(p.isEnabled(PluginType.GENERAL) ? " GENERAL" : "") +
|
||||
(p.isEnabled(PluginType.TREATMENT) ? " TREATMENT" : "") +
|
||||
(p.isEnabled(PluginType.SENSITIVITY) ? " SENSITIVITY" : "") +
|
||||
(p.isEnabled(PluginType.PROFILE) ? " PROFILE" : "") +
|
||||
(p.isEnabled(PluginType.APS) ? " APS" : "") +
|
||||
(p.isEnabled(PluginType.PUMP) ? " PUMP" : "") +
|
||||
(p.isEnabled(PluginType.CONSTRAINTS) ? " CONSTRAINTS" : "") +
|
||||
(p.isEnabled(PluginType.LOOP) ? " LOOP" : "") +
|
||||
(p.isEnabled(PluginType.BGSOURCE) ? " BGSOURCE" : "") +
|
||||
(p.isEnabled(PluginType.INSULIN) ? " INSULIN" : "")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -260,33 +306,47 @@ public class ConfigBuilderPlugin implements PluginBase, TreatmentsInterface {
|
|||
private void verifySelectionInCategories() {
|
||||
ArrayList<PluginBase> pluginsInCategory;
|
||||
|
||||
// PluginBase.APS
|
||||
activeAPS = this.determineActivePlugin(APSInterface.class, PluginBase.APS);
|
||||
// PluginType.APS
|
||||
activeAPS = this.determineActivePlugin(APSInterface.class, PluginType.APS);
|
||||
|
||||
// PluginBase.INSULIN
|
||||
activeInsulin = this.determineActivePlugin(InsulinInterface.class, PluginBase.INSULIN);
|
||||
// PluginType.INSULIN
|
||||
pluginsInCategory = MainApp.getSpecificPluginsList(PluginType.INSULIN);
|
||||
activeInsulin = (InsulinInterface) getTheOneEnabledInArray(pluginsInCategory, PluginType.INSULIN);
|
||||
if (activeInsulin == null) {
|
||||
activeInsulin = InsulinOrefRapidActingPlugin.getPlugin();
|
||||
InsulinOrefRapidActingPlugin.getPlugin().setPluginEnabled(PluginType.INSULIN, true);
|
||||
}
|
||||
this.setFragmentVisiblities(((PluginBase) activeInsulin).getName(), pluginsInCategory, PluginType.INSULIN);
|
||||
|
||||
// PluginBase.SENSITIVITY
|
||||
activeSensitivity = this.determineActivePlugin(SensitivityInterface.class, PluginBase.SENSITIVITY);
|
||||
// PluginType.SENSITIVITY
|
||||
pluginsInCategory = MainApp.getSpecificPluginsList(PluginType.SENSITIVITY);
|
||||
activeSensitivity = (SensitivityInterface) getTheOneEnabledInArray(pluginsInCategory, PluginType.SENSITIVITY);
|
||||
if (activeSensitivity == null) {
|
||||
activeSensitivity = SensitivityOref0Plugin.getPlugin();
|
||||
SensitivityOref0Plugin.getPlugin().setPluginEnabled(PluginType.SENSITIVITY, true);
|
||||
}
|
||||
this.setFragmentVisiblities(((PluginBase) activeSensitivity).getName(), pluginsInCategory, PluginType.SENSITIVITY);
|
||||
|
||||
// PluginBase.PROFILE
|
||||
activeProfile = this.determineActivePlugin(ProfileInterface.class, PluginBase.PROFILE);
|
||||
// PluginType.PROFILE
|
||||
activeProfile = this.determineActivePlugin(ProfileInterface.class, PluginType.PROFILE);
|
||||
|
||||
// PluginBase.BGSOURCE
|
||||
activeBgSource = this.determineActivePlugin(BgSourceInterface.class, PluginBase.BGSOURCE);
|
||||
// PluginType.BGSOURCE
|
||||
activeBgSource = this.determineActivePlugin(BgSourceInterface.class, PluginType.BGSOURCE);
|
||||
|
||||
// PluginBase.PUMP
|
||||
pluginsInCategory = MainApp.getSpecificPluginsList(PluginBase.PUMP);
|
||||
activePump = (PumpInterface) getTheOneEnabledInArray(pluginsInCategory, PluginBase.PUMP);
|
||||
if (activePump == null)
|
||||
activePump = VirtualPumpPlugin.getPlugin(); // for NSClient build
|
||||
this.setFragmentVisiblities(((PluginBase) activePump).getName(), pluginsInCategory, PluginBase.PUMP);
|
||||
// PluginType.PUMP
|
||||
pluginsInCategory = MainApp.getSpecificPluginsList(PluginType.PUMP);
|
||||
activePump = (PumpInterface) getTheOneEnabledInArray(pluginsInCategory, PluginType.PUMP);
|
||||
if (activePump == null) {
|
||||
activePump = VirtualPumpPlugin.getPlugin();
|
||||
VirtualPumpPlugin.getPlugin().setPluginEnabled(PluginType.PUMP, true);
|
||||
}
|
||||
this.setFragmentVisiblities(((PluginBase) activePump).getName(), pluginsInCategory, PluginType.PUMP);
|
||||
|
||||
// PluginBase.LOOP
|
||||
activeLoop = this.determineActivePlugin(PluginBase.LOOP);
|
||||
// PluginType.LOOP
|
||||
activeLoop = this.determineActivePlugin(PluginType.LOOP);
|
||||
|
||||
// PluginBase.TREATMENT
|
||||
activeTreatments = this.determineActivePlugin(PluginBase.TREATMENT);
|
||||
// PluginType.TREATMENT
|
||||
activeTreatments = this.determineActivePlugin(PluginType.TREATMENT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -298,14 +358,14 @@ public class ConfigBuilderPlugin implements PluginBase, TreatmentsInterface {
|
|||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
private <T> T determineActivePlugin(Class<T> pluginInterface, int pluginType) {
|
||||
private <T> T determineActivePlugin(Class<T> pluginInterface, PluginType pluginType) {
|
||||
ArrayList<PluginBase> pluginsInCategory;
|
||||
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(pluginInterface);
|
||||
|
||||
return this.determineActivePlugin(pluginsInCategory, pluginType);
|
||||
}
|
||||
|
||||
private <T> T determineActivePlugin(int pluginType) {
|
||||
private <T> T determineActivePlugin(PluginType pluginType) {
|
||||
ArrayList<PluginBase> pluginsInCategory;
|
||||
pluginsInCategory = MainApp.getSpecificPluginsList(pluginType);
|
||||
|
||||
|
@ -327,7 +387,7 @@ public class ConfigBuilderPlugin implements PluginBase, TreatmentsInterface {
|
|||
* @return
|
||||
*/
|
||||
private <T> T determineActivePlugin(ArrayList<PluginBase> pluginsInCategory,
|
||||
int pluginType) {
|
||||
PluginType pluginType) {
|
||||
T activePlugin = (T) getTheOneEnabledInArray(pluginsInCategory, pluginType);
|
||||
|
||||
if (activePlugin != null) {
|
||||
|
@ -339,7 +399,7 @@ public class ConfigBuilderPlugin implements PluginBase, TreatmentsInterface {
|
|||
}
|
||||
|
||||
private void setFragmentVisiblities(String activePluginName, ArrayList<PluginBase> pluginsInCategory,
|
||||
int pluginType) {
|
||||
PluginType pluginType) {
|
||||
if (Config.logConfigBuilder)
|
||||
log.debug("Selected interface: " + activePluginName);
|
||||
for (PluginBase p : pluginsInCategory) {
|
||||
|
@ -350,7 +410,7 @@ public class ConfigBuilderPlugin implements PluginBase, TreatmentsInterface {
|
|||
}
|
||||
|
||||
@Nullable
|
||||
private PluginBase getTheOneEnabledInArray(ArrayList<PluginBase> pluginsInCategory, int type) {
|
||||
private PluginBase getTheOneEnabledInArray(ArrayList<PluginBase> pluginsInCategory, PluginType type) {
|
||||
PluginBase found = null;
|
||||
for (PluginBase p : pluginsInCategory) {
|
||||
if (p.isEnabled(type) && found == null) {
|
||||
|
@ -361,8 +421,8 @@ public class ConfigBuilderPlugin implements PluginBase, TreatmentsInterface {
|
|||
}
|
||||
}
|
||||
// If none enabled, enable first one
|
||||
if (found == null && pluginsInCategory.size() > 0)
|
||||
found = pluginsInCategory.get(0);
|
||||
//if (found == null && pluginsInCategory.size() > 0)
|
||||
// found = pluginsInCategory.get(0);
|
||||
return found;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,9 +24,10 @@ import java.util.List;
|
|||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||
import info.nightscout.utils.FabricPrivacy;
|
||||
|
||||
public class ObjectivesFragment extends Fragment {
|
||||
public class ObjectivesFragment extends SubscriberFragment {
|
||||
private static Logger log = LoggerFactory.getLogger(ObjectivesFragment.class);
|
||||
|
||||
RecyclerView recyclerView;
|
||||
|
@ -214,15 +215,13 @@ public class ObjectivesFragment extends Fragment {
|
|||
return null;
|
||||
}
|
||||
|
||||
void updateGUI() {
|
||||
@Override
|
||||
public void updateGUI() {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null)
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
activity.runOnUiThread(() -> {
|
||||
RecyclerViewAdapter adapter = new RecyclerViewAdapter(ObjectivesPlugin.objectives);
|
||||
recyclerView.setAdapter(adapter);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,9 @@ import info.nightscout.androidaps.interfaces.APSInterface;
|
|||
import info.nightscout.androidaps.interfaces.Constraint;
|
||||
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.ConstraintsSafety.SafetyPlugin;
|
||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||
|
@ -28,7 +31,7 @@ import info.nightscout.utils.SP;
|
|||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
|
||||
public class ObjectivesPlugin extends PluginBase implements ConstraintsInterface {
|
||||
private static Logger log = LoggerFactory.getLogger(ObjectivesPlugin.class);
|
||||
|
||||
private static ObjectivesPlugin objectivesPlugin;
|
||||
|
@ -42,77 +45,27 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
|
|||
|
||||
public static List<Objective> objectives;
|
||||
|
||||
private boolean fragmentVisible = true;
|
||||
|
||||
private ObjectivesPlugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.CONSTRAINTS)
|
||||
.fragmentClass(ObjectivesFragment.class.getName())
|
||||
.alwaysEnabled(true)
|
||||
.pluginName(R.string.objectives)
|
||||
.shortName(R.string.objectives_shortname)
|
||||
);
|
||||
initializeData();
|
||||
loadProgress();
|
||||
MainApp.bus().register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return ObjectivesFragment.class.getName();
|
||||
public boolean specialEnableCondition() {
|
||||
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
return pump == null || pump.getPumpDescription().isTempBasalCapable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return PluginBase.CONSTRAINTS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MainApp.instance().getString(R.string.objectives);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameShort() {
|
||||
String name = MainApp.gs(R.string.objectives_shortname);
|
||||
if (!name.trim().isEmpty()) {
|
||||
//only if translation exists
|
||||
return name;
|
||||
}
|
||||
// use long name as fallback
|
||||
return getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return type == CONSTRAINTS && ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return type == CONSTRAINTS && fragmentVisible && !Config.NSCLIENT && !Config.G5UPLOADER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFragment() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInList(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean fragmentEnabled) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == CONSTRAINTS) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferencesId() {
|
||||
return -1;
|
||||
public boolean specialShowInListCondition() {
|
||||
return !Config.NSCLIENT && !Config.G5UPLOADER;
|
||||
}
|
||||
|
||||
public class Objective {
|
||||
|
@ -170,23 +123,23 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
|
|||
RequirementResult requirementsMet(Integer objNum) {
|
||||
switch (objNum) {
|
||||
case 0:
|
||||
boolean isVirtualPump = VirtualPumpPlugin.getPlugin().isEnabled(PluginBase.PUMP);
|
||||
boolean isVirtualPump = VirtualPumpPlugin.getPlugin().isEnabled(PluginType.PUMP);
|
||||
boolean vpUploadEnabled = SP.getBoolean("virtualpump_uploadstatus", false);
|
||||
boolean vpUploadNeeded = !isVirtualPump || vpUploadEnabled;
|
||||
boolean hasBGData = DatabaseHelper.lastBg() != null;
|
||||
|
||||
boolean apsEnabled = false;
|
||||
APSInterface usedAPS = ConfigBuilderPlugin.getActiveAPS();
|
||||
if (usedAPS != null && ((PluginBase) usedAPS).isEnabled(PluginBase.APS))
|
||||
if (usedAPS != null && ((PluginBase) usedAPS).isEnabled(PluginType.APS))
|
||||
apsEnabled = true;
|
||||
|
||||
return new RequirementResult(hasBGData && bgIsAvailableInNS && pumpStatusIsAvailableInNS && NSClientPlugin.getPlugin().hasWritePermission() && LoopPlugin.getPlugin().isEnabled(PluginBase.LOOP) && apsEnabled && vpUploadNeeded,
|
||||
return new RequirementResult(hasBGData && bgIsAvailableInNS && pumpStatusIsAvailableInNS && NSClientPlugin.getPlugin().hasWritePermission() && LoopPlugin.getPlugin().isEnabled(PluginType.LOOP) && apsEnabled && vpUploadNeeded,
|
||||
MainApp.gs(R.string.objectives_bgavailableinns) + ": " + yesOrNo(bgIsAvailableInNS)
|
||||
+ "\n" + MainApp.gs(R.string.nsclienthaswritepermission) + ": " + yesOrNo(NSClientPlugin.getPlugin().hasWritePermission())
|
||||
+ (isVirtualPump ? "\n" + MainApp.gs(R.string.virtualpump_uploadstatus_title) + ": " + yesOrNo(vpUploadEnabled) : "")
|
||||
+ "\n" + MainApp.gs(R.string.objectives_pumpstatusavailableinns) + ": " + yesOrNo(pumpStatusIsAvailableInNS)
|
||||
+ "\n" + MainApp.gs(R.string.hasbgdata) + ": " + yesOrNo(hasBGData)
|
||||
+ "\n" + MainApp.gs(R.string.loopenabled) + ": " + yesOrNo(LoopPlugin.getPlugin().isEnabled(PluginBase.LOOP))
|
||||
+ "\n" + MainApp.gs(R.string.loopenabled) + ": " + yesOrNo(LoopPlugin.getPlugin().isEnabled(PluginType.LOOP))
|
||||
+ "\n" + MainApp.gs(R.string.apsselected) + ": " + yesOrNo(apsEnabled)
|
||||
);
|
||||
case 1:
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
package info.nightscout.androidaps.plugins.ConstraintsSafety;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.ConstraintChecker;
|
||||
|
@ -11,6 +8,8 @@ import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
|||
import info.nightscout.androidaps.interfaces.Constraint;
|
||||
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSMA.OpenAPSMAPlugin;
|
||||
|
@ -23,8 +22,7 @@ import info.nightscout.utils.SP;
|
|||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class SafetyPlugin implements PluginBase, ConstraintsInterface {
|
||||
private static Logger log = LoggerFactory.getLogger(SafetyPlugin.class);
|
||||
public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
|
||||
|
||||
static SafetyPlugin plugin = null;
|
||||
|
||||
|
@ -34,64 +32,15 @@ public class SafetyPlugin implements PluginBase, ConstraintsInterface {
|
|||
return plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return PluginBase.CONSTRAINTS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MainApp.instance().getString(R.string.safety);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameShort() {
|
||||
// use long name as fallback (no tabs)
|
||||
return getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return type == CONSTRAINTS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFragment() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInList(int type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean fragmentEnabled) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferencesId() {
|
||||
return R.xml.pref_safety;
|
||||
public SafetyPlugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.CONSTRAINTS)
|
||||
.neverVisible(true)
|
||||
.alwaysEnabled(true)
|
||||
.showInList(false)
|
||||
.pluginName(R.string.safety)
|
||||
.preferencesId(R.xml.pref_safety)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -215,11 +164,11 @@ public class SafetyPlugin implements PluginBase, ConstraintsInterface {
|
|||
double maxIobPref = SP.getDouble(R.string.key_openapsma_max_iob, 1.5d);
|
||||
maxIob.setIfSmaller(maxIobPref, String.format(MainApp.gs(R.string.limitingiob), maxIobPref, MainApp.gs(R.string.maxvalueinpreferences)), this);
|
||||
|
||||
if (OpenAPSMAPlugin.getPlugin().isEnabled(PluginBase.APS))
|
||||
if (OpenAPSMAPlugin.getPlugin().isEnabled(PluginType.APS))
|
||||
maxIob.setIfSmaller(HardLimits.maxIobAMA(), String.format(MainApp.gs(R.string.limitingiob), HardLimits.maxIobAMA(), MainApp.gs(R.string.hardlimit)), this);
|
||||
if (OpenAPSAMAPlugin.getPlugin().isEnabled(PluginBase.APS))
|
||||
if (OpenAPSAMAPlugin.getPlugin().isEnabled(PluginType.APS))
|
||||
maxIob.setIfSmaller(HardLimits.maxIobAMA(), String.format(MainApp.gs(R.string.limitingiob), HardLimits.maxIobAMA(), MainApp.gs(R.string.hardlimit)), this);
|
||||
if (OpenAPSSMBPlugin.getPlugin().isEnabled(PluginBase.APS))
|
||||
if (OpenAPSSMBPlugin.getPlugin().isEnabled(PluginType.APS))
|
||||
maxIob.setIfSmaller(HardLimits.maxIobSMB(), String.format(MainApp.gs(R.string.limitingiob), HardLimits.maxIobSMB(), MainApp.gs(R.string.hardlimit)), this);
|
||||
return maxIob;
|
||||
}
|
||||
|
|
|
@ -1,90 +1,33 @@
|
|||
package info.nightscout.androidaps.plugins.Food;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class FoodPlugin implements PluginBase {
|
||||
private boolean fragmentEnabled = true;
|
||||
private boolean fragmentVisible = false;
|
||||
public class FoodPlugin extends PluginBase {
|
||||
|
||||
private static FoodPlugin plugin = null;
|
||||
|
||||
private FoodService service;
|
||||
|
||||
private FoodPlugin() {
|
||||
this.service = new FoodService();
|
||||
}
|
||||
|
||||
public static FoodPlugin getPlugin() {
|
||||
if (plugin == null)
|
||||
plugin = new FoodPlugin();
|
||||
return plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return FoodFragment.class.getName();
|
||||
}
|
||||
private FoodService service;
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return PluginBase.GENERAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MainApp.instance().getString(R.string.food);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameShort() {
|
||||
// use long name as fallback (not visible in tabs)
|
||||
return getName();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return type == GENERAL && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return type == GENERAL && fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFragment() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInList(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == GENERAL) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == GENERAL) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferencesId() {
|
||||
return -1;
|
||||
private FoodPlugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.GENERAL)
|
||||
.fragmentClass(FoodFragment.class.getName())
|
||||
.pluginName(R.string.food)
|
||||
.shortName(R.string.food_short)
|
||||
);
|
||||
this.service = new FoodService();
|
||||
}
|
||||
|
||||
public FoodService getService() {
|
||||
|
|
|
@ -7,15 +7,14 @@ import info.nightscout.androidaps.data.Iob;
|
|||
import info.nightscout.androidaps.db.Treatment;
|
||||
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
|
||||
/**
|
||||
* Created by mike on 17.04.2017.
|
||||
*/
|
||||
|
||||
public class InsulinFastactingPlugin implements PluginBase, InsulinInterface {
|
||||
|
||||
private boolean fragmentEnabled = true;
|
||||
private boolean fragmentVisible = false;
|
||||
public class InsulinFastactingPlugin extends PluginBase implements InsulinInterface {
|
||||
|
||||
private static InsulinFastactingPlugin plugin = null;
|
||||
|
||||
|
@ -25,64 +24,13 @@ public class InsulinFastactingPlugin implements PluginBase, InsulinInterface {
|
|||
return plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return INSULIN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return InsulinFragment.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MainApp.sResources.getString(R.string.fastactinginsulin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameShort() {
|
||||
return MainApp.sResources.getString(R.string.insulin_shortname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return type == INSULIN && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return type == INSULIN && fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFragment() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInList(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == INSULIN) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == INSULIN) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferencesId() {
|
||||
return -1;
|
||||
public InsulinFastactingPlugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.INSULIN)
|
||||
.fragmentClass(InsulinFragment.class.getName())
|
||||
.pluginName(R.string.fastactinginsulin)
|
||||
.shortName(R.string.insulin_shortname)
|
||||
);
|
||||
}
|
||||
|
||||
// Insulin interface
|
||||
|
|
|
@ -8,15 +8,14 @@ import info.nightscout.androidaps.data.Profile;
|
|||
import info.nightscout.androidaps.db.Treatment;
|
||||
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
|
||||
/**
|
||||
* Created by mike on 17.04.2017.
|
||||
*/
|
||||
|
||||
public class InsulinFastactingProlongedPlugin implements PluginBase, InsulinInterface {
|
||||
|
||||
private boolean fragmentEnabled = false;
|
||||
private boolean fragmentVisible = false;
|
||||
public class InsulinFastactingProlongedPlugin extends PluginBase implements InsulinInterface {
|
||||
|
||||
private static InsulinFastactingProlongedPlugin plugin = null;
|
||||
|
||||
|
@ -26,64 +25,13 @@ public class InsulinFastactingProlongedPlugin implements PluginBase, InsulinInte
|
|||
return plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return INSULIN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return InsulinFragment.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MainApp.sResources.getString(R.string.fastactinginsulinprolonged);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameShort() {
|
||||
return MainApp.sResources.getString(R.string.insulin_shortname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return type == INSULIN && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return type == INSULIN && fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFragment() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInList(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == INSULIN) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == INSULIN) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferencesId() {
|
||||
return -1;
|
||||
public InsulinFastactingProlongedPlugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.INSULIN)
|
||||
.fragmentClass(InsulinFragment.class.getName())
|
||||
.pluginName(R.string.fastactinginsulinprolonged)
|
||||
.shortName(R.string.insulin_shortname)
|
||||
);
|
||||
}
|
||||
|
||||
// Insulin interface
|
||||
|
|
|
@ -8,42 +8,28 @@ import info.nightscout.androidaps.data.Iob;
|
|||
import info.nightscout.androidaps.db.Treatment;
|
||||
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||
|
||||
/**
|
||||
* Created by adrian on 13.08.2017.
|
||||
*/
|
||||
|
||||
public abstract class InsulinOrefBasePlugin implements PluginBase, InsulinInterface {
|
||||
public abstract class InsulinOrefBasePlugin extends PluginBase implements InsulinInterface {
|
||||
|
||||
public static double MIN_DIA = 5;
|
||||
|
||||
long lastWarned = 0;
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return INSULIN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameShort() {
|
||||
return MainApp.sResources.getString(R.string.insulin_shortname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFragment() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInList(int type) {
|
||||
return true;
|
||||
public InsulinOrefBasePlugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.INSULIN)
|
||||
.fragmentClass(InsulinFragment.class.getName())
|
||||
.pluginName(R.string.fastactinginsulin)
|
||||
.shortName(R.string.insulin_shortname)
|
||||
);
|
||||
}
|
||||
|
||||
public Bus getBus() {
|
||||
|
@ -53,7 +39,7 @@ public abstract class InsulinOrefBasePlugin implements PluginBase, InsulinInterf
|
|||
@Override
|
||||
public double getDia() {
|
||||
double dia = getUserDefinedDia();
|
||||
if(dia >= MIN_DIA){
|
||||
if (dia >= MIN_DIA) {
|
||||
return dia;
|
||||
} else {
|
||||
sendShortDiaNotification(dia);
|
||||
|
@ -62,7 +48,7 @@ public abstract class InsulinOrefBasePlugin implements PluginBase, InsulinInterf
|
|||
}
|
||||
|
||||
void sendShortDiaNotification(double dia) {
|
||||
if((System.currentTimeMillis() - lastWarned) > 60*1000) {
|
||||
if ((System.currentTimeMillis() - lastWarned) > 60 * 1000) {
|
||||
lastWarned = System.currentTimeMillis();
|
||||
Notification notification = new Notification(Notification.SHORT_DIA, String.format(this.getNotificationPattern(), dia, MIN_DIA), Notification.URGENT);
|
||||
this.getBus().post(new EventNewNotification(notification));
|
||||
|
@ -92,7 +78,7 @@ public abstract class InsulinOrefBasePlugin implements PluginBase, InsulinInterf
|
|||
long bolusTime = treatment.date;
|
||||
double t = (time - bolusTime) / 1000d / 60d;
|
||||
|
||||
double td = getDia()*60; //getDIA() always >= MIN_DIA
|
||||
double td = getDia() * 60; //getDIA() always >= MIN_DIA
|
||||
double tp = peak;
|
||||
|
||||
// force the IOB to 0 if over DIA hours have passed
|
||||
|
@ -111,7 +97,7 @@ public abstract class InsulinOrefBasePlugin implements PluginBase, InsulinInterf
|
|||
public String getComment() {
|
||||
String comment = commentStandardText();
|
||||
double userDia = getUserDefinedDia();
|
||||
if(userDia < MIN_DIA){
|
||||
if (userDia < MIN_DIA) {
|
||||
comment += "\n" + String.format(MainApp.sResources.getString(R.string.dia_too_short), userDia, MIN_DIA);
|
||||
}
|
||||
return comment;
|
||||
|
|
|
@ -10,9 +10,6 @@ import info.nightscout.utils.SP;
|
|||
|
||||
public class InsulinOrefFreePeakPlugin extends InsulinOrefBasePlugin {
|
||||
|
||||
private boolean fragmentEnabled = false;
|
||||
private boolean fragmentVisible = false;
|
||||
|
||||
private static InsulinOrefFreePeakPlugin plugin = null;
|
||||
|
||||
public static InsulinOrefFreePeakPlugin getPlugin() {
|
||||
|
@ -21,24 +18,20 @@ public class InsulinOrefFreePeakPlugin extends InsulinOrefBasePlugin {
|
|||
return plugin;
|
||||
}
|
||||
|
||||
public static final int DEFAULT_PEAK = 75;
|
||||
private static final int DEFAULT_PEAK = 75;
|
||||
|
||||
private InsulinOrefFreePeakPlugin() {
|
||||
super();
|
||||
pluginDescription
|
||||
.pluginName(R.string.free_peak_oref)
|
||||
.preferencesId(R.xml.pref_insulinoreffreepeak);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return OREF_FREE_PEAK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MainApp.sResources.getString(R.string.free_peak_oref);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return InsulinFragment.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFriendlyName() {
|
||||
return MainApp.sResources.getString(R.string.free_peak_oref);
|
||||
}
|
||||
|
@ -48,31 +41,6 @@ public class InsulinOrefFreePeakPlugin extends InsulinOrefBasePlugin {
|
|||
return MainApp.sResources.getString(R.string.insulin_peak_time) + ": " + getPeak();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return type == INSULIN && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return type == INSULIN && fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == INSULIN) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == INSULIN) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferencesId() {
|
||||
return R.xml.pref_insulinoreffreepeak;
|
||||
}
|
||||
|
||||
@Override
|
||||
int getPeak() {
|
||||
return SP.getInt(R.string.key_insulin_oref_peak, DEFAULT_PEAK);
|
||||
|
|
|
@ -9,9 +9,6 @@ import info.nightscout.androidaps.R;
|
|||
|
||||
public class InsulinOrefRapidActingPlugin extends InsulinOrefBasePlugin {
|
||||
|
||||
private boolean fragmentEnabled = false;
|
||||
private boolean fragmentVisible = false;
|
||||
|
||||
private static InsulinOrefRapidActingPlugin plugin = null;
|
||||
|
||||
public static InsulinOrefRapidActingPlugin getPlugin() {
|
||||
|
@ -20,23 +17,19 @@ public class InsulinOrefRapidActingPlugin extends InsulinOrefBasePlugin {
|
|||
return plugin;
|
||||
}
|
||||
|
||||
public static final int PEAK = 75;
|
||||
private static final int PEAK = 75;
|
||||
|
||||
private InsulinOrefRapidActingPlugin() {
|
||||
super();
|
||||
pluginDescription
|
||||
.pluginName(R.string.rapid_acting_oref);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return OREF_RAPID_ACTING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MainApp.sResources.getString(R.string.rapid_acting_oref);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return InsulinFragment.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFriendlyName() {
|
||||
return MainApp.sResources.getString(R.string.rapid_acting_oref);
|
||||
|
@ -47,31 +40,6 @@ public class InsulinOrefRapidActingPlugin extends InsulinOrefBasePlugin {
|
|||
return MainApp.sResources.getString(R.string.fastactinginsulincomment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return type == INSULIN && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return type == INSULIN && fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == INSULIN) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == INSULIN) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferencesId() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
int getPeak() {
|
||||
return PEAK;
|
||||
|
|
|
@ -9,9 +9,6 @@ import info.nightscout.androidaps.R;
|
|||
|
||||
public class InsulinOrefUltraRapidActingPlugin extends InsulinOrefBasePlugin {
|
||||
|
||||
private boolean fragmentEnabled = false;
|
||||
private boolean fragmentVisible = false;
|
||||
|
||||
private static InsulinOrefUltraRapidActingPlugin plugin = null;
|
||||
|
||||
public static InsulinOrefUltraRapidActingPlugin getPlugin() {
|
||||
|
@ -20,7 +17,13 @@ public class InsulinOrefUltraRapidActingPlugin extends InsulinOrefBasePlugin {
|
|||
return plugin;
|
||||
}
|
||||
|
||||
public static final int PEAK = 55;
|
||||
private static final int PEAK = 55;
|
||||
|
||||
private InsulinOrefUltraRapidActingPlugin() {
|
||||
super();
|
||||
pluginDescription
|
||||
.pluginName(R.string.ultrarapid_oref);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
|
@ -32,11 +35,6 @@ public class InsulinOrefUltraRapidActingPlugin extends InsulinOrefBasePlugin {
|
|||
return MainApp.sResources.getString(R.string.ultrarapid_oref);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return InsulinFragment.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFriendlyName() {
|
||||
return MainApp.sResources.getString(R.string.ultrarapid_oref);
|
||||
|
@ -47,31 +45,6 @@ public class InsulinOrefUltraRapidActingPlugin extends InsulinOrefBasePlugin {
|
|||
return MainApp.sResources.getString(R.string.ultrafastactinginsulincomment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return type == INSULIN && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return type == INSULIN && fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == INSULIN) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == INSULIN) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferencesId() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
int getPeak() {
|
||||
return PEAK;
|
||||
|
|
|
@ -12,6 +12,7 @@ import info.nightscout.androidaps.R;
|
|||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.db.Treatment;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.plugins.SensitivityAAPS.SensitivityAAPSPlugin;
|
||||
import info.nightscout.androidaps.plugins.SensitivityWeightedAverage.SensitivityWeightedAveragePlugin;
|
||||
import info.nightscout.utils.SP;
|
||||
|
@ -33,7 +34,7 @@ public class AutosensData {
|
|||
time = t.date;
|
||||
carbs = t.carbs;
|
||||
remaining = t.carbs;
|
||||
if (SensitivityAAPSPlugin.getPlugin().isEnabled(PluginBase.SENSITIVITY) || SensitivityWeightedAveragePlugin.getPlugin().isEnabled(PluginBase.SENSITIVITY)) {
|
||||
if (SensitivityAAPSPlugin.getPlugin().isEnabled(PluginType.SENSITIVITY) || SensitivityWeightedAveragePlugin.getPlugin().isEnabled(PluginType.SENSITIVITY)) {
|
||||
double maxAbsorptionHours = SP.getDouble(R.string.key_absorption_maxtime, 4d);
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile(t.date);
|
||||
double sens = Profile.toMgdl(profile.getIsf(t.date), profile.getUnits());
|
||||
|
|
|
@ -29,6 +29,8 @@ import info.nightscout.androidaps.events.EventNewBG;
|
|||
import info.nightscout.androidaps.events.EventNewBasalProfile;
|
||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventNewHistoryData;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSSMB.OpenAPSSMBPlugin;
|
||||
|
@ -38,8 +40,16 @@ import info.nightscout.utils.DateUtil;
|
|||
* Created by mike on 24.04.2017.
|
||||
*/
|
||||
|
||||
public class IobCobCalculatorPlugin implements PluginBase {
|
||||
private static Logger log = LoggerFactory.getLogger(IobCobCalculatorPlugin.class);
|
||||
public class IobCobCalculatorPlugin extends PluginBase {
|
||||
private Logger log = LoggerFactory.getLogger(IobCobCalculatorPlugin.class);
|
||||
|
||||
private static IobCobCalculatorPlugin plugin = null;
|
||||
|
||||
public static IobCobCalculatorPlugin getPlugin() {
|
||||
if (plugin == null)
|
||||
plugin = new IobCobCalculatorPlugin();
|
||||
return plugin;
|
||||
}
|
||||
|
||||
private LongSparseArray<IobTotal> iobTable = new LongSparseArray<>(); // oldest at index 0
|
||||
private LongSparseArray<AutosensData> autosensDataTable = new LongSparseArray<>(); // oldest at index 0
|
||||
|
@ -55,12 +65,26 @@ public class IobCobCalculatorPlugin implements PluginBase {
|
|||
boolean stopCalculationTrigger = false;
|
||||
private IobCobThread thread = null;
|
||||
|
||||
private static IobCobCalculatorPlugin plugin = null;
|
||||
public IobCobCalculatorPlugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.GENERAL)
|
||||
.pluginName(R.string.iobcobcalculator)
|
||||
.showInList(false)
|
||||
.neverVisible(true)
|
||||
.alwaysEnabled(true)
|
||||
);
|
||||
}
|
||||
|
||||
public static IobCobCalculatorPlugin getPlugin() {
|
||||
if (plugin == null)
|
||||
plugin = new IobCobCalculatorPlugin();
|
||||
return plugin;
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
MainApp.bus().register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
MainApp.bus().unregister(this);
|
||||
}
|
||||
|
||||
public LongSparseArray<AutosensData> getAutosensDataTable() {
|
||||
|
@ -71,70 +95,6 @@ public class IobCobCalculatorPlugin implements PluginBase {
|
|||
return bucketed_data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return GENERAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "IOB COB Calculator";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameShort() {
|
||||
return "IOC";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return type == GENERAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFragment() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInList(int type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean fragmentEnabled) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferencesId() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public IobCobCalculatorPlugin() {
|
||||
MainApp.bus().register(this);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<BgReading> getBucketedData(long fromTime) {
|
||||
//log.debug("Locking getBucketedData");
|
||||
|
@ -323,7 +283,7 @@ public class IobCobCalculatorPlugin implements PluginBase {
|
|||
log.debug("Bucketed data created. Size: " + bucketed_data.size());
|
||||
}
|
||||
|
||||
public static long oldestDataAvailable() {
|
||||
public long oldestDataAvailable() {
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
long oldestDataAvailable = MainApp.getConfigBuilder().oldestDataAvailable();
|
||||
|
@ -349,7 +309,7 @@ public class IobCobCalculatorPlugin implements PluginBase {
|
|||
}
|
||||
IobTotal bolusIob = MainApp.getConfigBuilder().getCalculationToTimeTreatments(time).round();
|
||||
IobTotal basalIob = MainApp.getConfigBuilder().getCalculationToTimeTempBasals(time).round();
|
||||
if (OpenAPSSMBPlugin.getPlugin().isEnabled(PluginBase.APS)) {
|
||||
if (OpenAPSSMBPlugin.getPlugin().isEnabled(PluginType.APS)) {
|
||||
// Add expected zere temp basal for next 240 mins
|
||||
IobTotal basalIobWithZeroTemp = basalIob.copy();
|
||||
TemporaryBasal t = new TemporaryBasal()
|
||||
|
@ -447,7 +407,7 @@ public class IobCobCalculatorPlugin implements PluginBase {
|
|||
log.debug("AUTOSENSDATA null: autosensDataTable empty (" + reason + ")");
|
||||
return null;
|
||||
}
|
||||
AutosensData data = null;
|
||||
AutosensData data;
|
||||
try {
|
||||
data = autosensDataTable.valueAt(autosensDataTable.size() - 1);
|
||||
} catch (Exception e) {
|
||||
|
@ -461,8 +421,6 @@ public class IobCobCalculatorPlugin implements PluginBase {
|
|||
log.debug("AUTOSENSDATA null: data is old (" + reason + ") size()=" + autosensDataTable.size() + " lastdata=" + DateUtil.dateAndTimeString(data.time));
|
||||
return null;
|
||||
} else {
|
||||
if (data == null)
|
||||
log.debug("AUTOSENSDATA null: data == null (" + " " + reason + ") size()=" + autosensDataTable.size() + " lastdata=" + DateUtil.dateAndTimeString(data.time));
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,9 +26,11 @@ import info.nightscout.androidaps.data.PumpEnactResult;
|
|||
import info.nightscout.androidaps.events.EventNewBG;
|
||||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||
import info.nightscout.androidaps.interfaces.APSInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.interfaces.Constraint;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished;
|
||||
import info.nightscout.androidaps.plugins.Loop.events.EventLoopSetLastRunGui;
|
||||
|
@ -43,7 +45,7 @@ import info.nightscout.utils.SP;
|
|||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class LoopPlugin implements PluginBase {
|
||||
public class LoopPlugin extends PluginBase {
|
||||
private static Logger log = LoggerFactory.getLogger(LoopPlugin.class);
|
||||
|
||||
protected static LoopPlugin loopPlugin;
|
||||
|
@ -55,9 +57,6 @@ public class LoopPlugin implements PluginBase {
|
|||
return loopPlugin;
|
||||
}
|
||||
|
||||
private boolean pluginEnabled = false;
|
||||
private boolean fragmentVisible = false;
|
||||
|
||||
private long loopSuspendedTill = 0L; // end of manual loop suspend
|
||||
private boolean isSuperBolus = false;
|
||||
private boolean isDisconnected = false;
|
||||
|
@ -76,78 +75,34 @@ public class LoopPlugin implements PluginBase {
|
|||
static public LastRun lastRun = null;
|
||||
|
||||
public LoopPlugin() {
|
||||
MainApp.bus().register(this);
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.LOOP)
|
||||
.fragmentClass(LoopFragment.class.getName())
|
||||
.pluginName(R.string.loop)
|
||||
.shortName(R.string.loop_shortname)
|
||||
.preferencesId(R.xml.pref_closedmode)
|
||||
);
|
||||
loopSuspendedTill = SP.getLong("loopSuspendedTill", 0L);
|
||||
isSuperBolus = SP.getBoolean("isSuperBolus", false);
|
||||
isDisconnected = SP.getBoolean("isDisconnected", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return LoopFragment.class.getName();
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
MainApp.bus().register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return PluginBase.LOOP;
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
MainApp.bus().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MainApp.instance().gs(R.string.loop);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameShort() {
|
||||
String name = MainApp.gs(R.string.loop_shortname);
|
||||
if (!name.trim().isEmpty()) {
|
||||
//only if translation exists
|
||||
return name;
|
||||
}
|
||||
// use long name as fallback
|
||||
return getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
boolean pumpCapable = ConfigBuilderPlugin.getActivePump() == null || ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable;
|
||||
return type == LOOP && pluginEnabled && pumpCapable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
boolean pumpCapable = ConfigBuilderPlugin.getActivePump() == null || ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable;
|
||||
return type == LOOP && fragmentVisible && pumpCapable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFragment() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInList(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean pluginEnabled) {
|
||||
if (type == LOOP) this.pluginEnabled = pluginEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == LOOP) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferencesId() {
|
||||
return R.xml.pref_closedmode;
|
||||
public boolean specialEnableCondition() {
|
||||
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
return pump == null || pump.getPumpDescription().isTempBasalCapable;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
@ -266,7 +221,7 @@ public class LoopPlugin implements PluginBase {
|
|||
final PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
APSResult result = null;
|
||||
|
||||
if (!isEnabled(PluginBase.LOOP))
|
||||
if (!isEnabled(PluginType.LOOP))
|
||||
return;
|
||||
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
|
@ -281,7 +236,7 @@ public class LoopPlugin implements PluginBase {
|
|||
if (pump.getBaseBasalRate() < 0.01d) return;
|
||||
|
||||
APSInterface usedAPS = ConfigBuilderPlugin.getActiveAPS();
|
||||
if (usedAPS != null && ((PluginBase) usedAPS).isEnabled(PluginBase.APS)) {
|
||||
if (usedAPS != null && ((PluginBase) usedAPS).isEnabled(PluginType.APS)) {
|
||||
usedAPS.invoke(initiator);
|
||||
result = usedAPS.getLastAPSResult();
|
||||
}
|
||||
|
|
|
@ -24,6 +24,8 @@ import info.nightscout.androidaps.MainApp;
|
|||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.events.EventAppExit;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientNewLog;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientStatus;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientUpdateGUI;
|
||||
|
@ -31,7 +33,7 @@ import info.nightscout.androidaps.plugins.NSClientInternal.services.NSClientServ
|
|||
import info.nightscout.utils.SP;
|
||||
import info.nightscout.utils.ToastUtils;
|
||||
|
||||
public class NSClientPlugin implements PluginBase {
|
||||
public class NSClientPlugin extends PluginBase {
|
||||
private static Logger log = LoggerFactory.getLogger(NSClientPlugin.class);
|
||||
|
||||
static NSClientPlugin nsClientPlugin;
|
||||
|
@ -43,9 +45,6 @@ public class NSClientPlugin implements PluginBase {
|
|||
return nsClientPlugin;
|
||||
}
|
||||
|
||||
private boolean fragmentEnabled = true;
|
||||
private boolean fragmentVisible = true;
|
||||
|
||||
public Handler handler;
|
||||
|
||||
private final List<EventNSClientNewLog> listLog = new ArrayList<>();
|
||||
|
@ -58,8 +57,14 @@ public class NSClientPlugin implements PluginBase {
|
|||
|
||||
public NSClientService nsClientService = null;
|
||||
|
||||
NSClientPlugin() {
|
||||
MainApp.bus().register(this);
|
||||
public NSClientPlugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.GENERAL)
|
||||
.fragmentClass(NSClientFragment.class.getName())
|
||||
.pluginName(R.string.nsclientinternal)
|
||||
.shortName(R.string.nsclientinternal_shortname)
|
||||
.preferencesId(R.xml.pref_nsclientinternal)
|
||||
);
|
||||
paused = SP.getBoolean(R.string.key_nsclientinternal_paused, false);
|
||||
autoscroll = SP.getBoolean(R.string.key_nsclientinternal_autoscroll, true);
|
||||
|
||||
|
@ -68,78 +73,28 @@ public class NSClientPlugin implements PluginBase {
|
|||
handlerThread.start();
|
||||
handler = new Handler(handlerThread.getLooper());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
MainApp.bus().register(this);
|
||||
Context context = MainApp.instance().getApplicationContext();
|
||||
Intent intent = new Intent(context, NSClientService.class);
|
||||
context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return PluginBase.GENERAL;
|
||||
protected void onStop() {
|
||||
MainApp.bus().unregister(this);
|
||||
Context context = MainApp.instance().getApplicationContext();
|
||||
context.unbindService(mConnection);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return NSClientFragment.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MainApp.sResources.getString(R.string.nsclientinternal);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameShort() {
|
||||
String name = MainApp.sResources.getString(R.string.nsclientinternal_shortname);
|
||||
if (!name.trim().isEmpty()) {
|
||||
//only if translation exists
|
||||
return name;
|
||||
}
|
||||
// use long name as fallback
|
||||
return getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return type == GENERAL && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return type == GENERAL && fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFragment() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInList(int type) {
|
||||
public boolean specialShowInListCondition() {
|
||||
return !Config.NSCLIENT && !Config.G5UPLOADER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == GENERAL) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == GENERAL) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferencesId() {
|
||||
return R.xml.pref_nsclientinternal;
|
||||
}
|
||||
|
||||
private ServiceConnection mConnection = new ServiceConnection() {
|
||||
|
||||
public void onServiceDisconnected(ComponentName name) {
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.slf4j.LoggerFactory;
|
|||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientPlugin;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.AlarmAck;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.services.NSClientService;
|
||||
|
@ -27,7 +28,7 @@ public class AckAlarmReceiver extends BroadcastReceiver {
|
|||
PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
|
||||
AckAlarmReceiver.class.getSimpleName());
|
||||
NSClientPlugin nsClientPlugin = MainApp.getSpecificPlugin(NSClientPlugin.class);
|
||||
if (!nsClientPlugin.isEnabled(PluginBase.GENERAL)) {
|
||||
if (!nsClientPlugin.isEnabled(PluginType.GENERAL)) {
|
||||
return;
|
||||
}
|
||||
if (SP.getBoolean(R.string.key_ns_noupload, false)) {
|
||||
|
|
|
@ -14,7 +14,7 @@ import org.slf4j.LoggerFactory;
|
|||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.db.DbRequest;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientPlugin;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastTreatment;
|
||||
|
@ -106,7 +106,7 @@ public class DBAccessReceiver extends BroadcastReceiver {
|
|||
|
||||
public boolean shouldUpload() {
|
||||
NSClientPlugin nsClientPlugin = MainApp.getSpecificPlugin(NSClientPlugin.class);
|
||||
return nsClientPlugin.isEnabled(PluginBase.GENERAL) && !SP.getBoolean(R.string.key_ns_noupload, false);
|
||||
return nsClientPlugin.isEnabled(PluginType.GENERAL) && !SP.getBoolean(R.string.key_ns_noupload, false);
|
||||
}
|
||||
|
||||
public void generateTreatmentOfflineBroadcast(DbRequest request) {
|
||||
|
|
|
@ -34,6 +34,7 @@ import info.nightscout.androidaps.events.EventAppExit;
|
|||
import info.nightscout.androidaps.events.EventConfigBuilderChange;
|
||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientPlugin;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.acks.NSAddAck;
|
||||
|
@ -180,7 +181,7 @@ public class NSClientService extends Service {
|
|||
|
||||
@Subscribe
|
||||
public void onStatusEvent(EventConfigBuilderChange ev) {
|
||||
if (nsEnabled != MainApp.getSpecificPlugin(NSClientPlugin.class).isEnabled(PluginBase.GENERAL)) {
|
||||
if (nsEnabled != MainApp.getSpecificPlugin(NSClientPlugin.class).isEnabled(PluginType.GENERAL)) {
|
||||
latestDateInReceivedData = 0;
|
||||
destroy();
|
||||
initialize();
|
||||
|
@ -313,7 +314,7 @@ public class NSClientService extends Service {
|
|||
}
|
||||
|
||||
public void readPreferences() {
|
||||
nsEnabled = MainApp.getSpecificPlugin(NSClientPlugin.class).isEnabled(PluginBase.GENERAL);
|
||||
nsEnabled = MainApp.getSpecificPlugin(NSClientPlugin.class).isEnabled(PluginType.GENERAL);
|
||||
nsURL = SP.getString(R.string.key_nsclientinternal_url, "");
|
||||
nsAPISecret = SP.getString(R.string.key_nsclientinternal_api_secret, "");
|
||||
nsDevice = SP.getString("careportal_enteredby", "");
|
||||
|
|
|
@ -8,7 +8,6 @@ import java.io.IOException;
|
|||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.GlucoseStatus;
|
||||
|
@ -18,8 +17,9 @@ import info.nightscout.androidaps.data.Profile;
|
|||
import info.nightscout.androidaps.db.TempTarget;
|
||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||
import info.nightscout.androidaps.interfaces.APSInterface;
|
||||
import info.nightscout.androidaps.interfaces.Constraint;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult;
|
||||
|
@ -32,12 +32,11 @@ import info.nightscout.utils.DateUtil;
|
|||
import info.nightscout.utils.HardLimits;
|
||||
import info.nightscout.utils.Profiler;
|
||||
import info.nightscout.utils.Round;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
|
||||
public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
|
||||
private static Logger log = LoggerFactory.getLogger(OpenAPSAMAPlugin.class);
|
||||
|
||||
private static OpenAPSAMAPlugin openAPSAMAPlugin;
|
||||
|
@ -55,75 +54,26 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
|
|||
DetermineBasalResultAMA lastAPSResult = null;
|
||||
AutosensResult lastAutosensResult = null;
|
||||
|
||||
private boolean fragmentEnabled = false;
|
||||
private boolean fragmentVisible = false;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MainApp.instance().getString(R.string.openapsama);
|
||||
public OpenAPSAMAPlugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.APS)
|
||||
.fragmentClass(OpenAPSAMAFragment.class.getName())
|
||||
.pluginName(R.string.openapsama)
|
||||
.shortName(R.string.oaps_shortname)
|
||||
.preferencesId(R.xml.pref_openapsama)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameShort() {
|
||||
String name = MainApp.sResources.getString(R.string.oaps_shortname);
|
||||
if (!name.trim().isEmpty()) {
|
||||
//only if translation exists
|
||||
return name;
|
||||
}
|
||||
// use long name as fallback
|
||||
return getName();
|
||||
public boolean specialEnableCondition() {
|
||||
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
return pump == null || pump.getPumpDescription().isTempBasalCapable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
boolean pumpCapable = ConfigBuilderPlugin.getActivePump() == null || ConfigBuilderPlugin.getActivePump() != null && ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable;
|
||||
return type == APS && fragmentEnabled && pumpCapable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
boolean pumpCapable = ConfigBuilderPlugin.getActivePump() == null || ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable;
|
||||
return type == APS && fragmentVisible && pumpCapable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFragment() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInList(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == APS) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferencesId() {
|
||||
return R.xml.pref_openapsama;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == APS) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return PluginBase.APS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return OpenAPSAMAFragment.class.getName();
|
||||
public boolean specialShowInListCondition() {
|
||||
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
return pump == null || pump.getPumpDescription().isTempBasalCapable;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -159,7 +109,7 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!isEnabled(PluginBase.APS)) {
|
||||
if (!isEnabled(PluginType.APS)) {
|
||||
MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.instance().getString(R.string.openapsma_disabled)));
|
||||
if (Config.logAPSResult)
|
||||
log.debug(MainApp.instance().getString(R.string.openapsma_disabled));
|
||||
|
@ -221,7 +171,7 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
|
|||
|
||||
startPart = new Date();
|
||||
if (MainApp.getConstraintChecker().isAutosensModeEnabled().value()) {
|
||||
lastAutosensResult = IobCobCalculatorPlugin.getPlugin().detectSensitivityWithLock(IobCobCalculatorPlugin.oldestDataAvailable(), System.currentTimeMillis());
|
||||
lastAutosensResult = IobCobCalculatorPlugin.getPlugin().detectSensitivityWithLock(IobCobCalculatorPlugin.getPlugin().oldestDataAvailable(), System.currentTimeMillis());
|
||||
} else {
|
||||
lastAutosensResult = new AutosensResult();
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import java.io.IOException;
|
|||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.GlucoseStatus;
|
||||
|
@ -18,8 +17,9 @@ import info.nightscout.androidaps.data.Profile;
|
|||
import info.nightscout.androidaps.db.TempTarget;
|
||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||
import info.nightscout.androidaps.interfaces.APSInterface;
|
||||
import info.nightscout.androidaps.interfaces.Constraint;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.Loop.APSResult;
|
||||
|
@ -30,7 +30,6 @@ import info.nightscout.utils.DateUtil;
|
|||
import info.nightscout.utils.HardLimits;
|
||||
import info.nightscout.utils.Profiler;
|
||||
import info.nightscout.utils.Round;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static info.nightscout.utils.HardLimits.checkOnlyHardLimits;
|
||||
import static info.nightscout.utils.HardLimits.verifyHardLimits;
|
||||
|
@ -38,7 +37,7 @@ import static info.nightscout.utils.HardLimits.verifyHardLimits;
|
|||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class OpenAPSMAPlugin implements PluginBase, APSInterface {
|
||||
public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
|
||||
private static Logger log = LoggerFactory.getLogger(OpenAPSMAPlugin.class);
|
||||
|
||||
private static OpenAPSMAPlugin openAPSMAPlugin;
|
||||
|
@ -55,75 +54,26 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
|
|||
Date lastAPSRun = null;
|
||||
DetermineBasalResultMA lastAPSResult = null;
|
||||
|
||||
private boolean fragmentEnabled = false;
|
||||
private boolean fragmentVisible = false;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MainApp.instance().getString(R.string.openapsma);
|
||||
public OpenAPSMAPlugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.APS)
|
||||
.fragmentClass(OpenAPSMAFragment.class.getName())
|
||||
.pluginName(R.string.openapsma)
|
||||
.shortName(R.string.oaps_shortname)
|
||||
.preferencesId(R.xml.pref_openapsma)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameShort() {
|
||||
String name = MainApp.sResources.getString(R.string.oaps_shortname);
|
||||
if (!name.trim().isEmpty()) {
|
||||
//only if translation exists
|
||||
return name;
|
||||
}
|
||||
// use long name as fallback
|
||||
return getName();
|
||||
public boolean specialEnableCondition() {
|
||||
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
return pump == null || pump.getPumpDescription().isTempBasalCapable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
boolean pumpCapable = ConfigBuilderPlugin.getActivePump() == null || ConfigBuilderPlugin.getActivePump() != null && ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable;
|
||||
return type == APS && fragmentEnabled && pumpCapable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
boolean pumpCapable = ConfigBuilderPlugin.getActivePump() == null || ConfigBuilderPlugin.getActivePump() != null && ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable;
|
||||
return type == APS && fragmentVisible && pumpCapable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFragment() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInList(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == APS) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferencesId() {
|
||||
return R.xml.pref_openapsma;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == APS) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return PluginBase.APS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return OpenAPSMAFragment.class.getName();
|
||||
public boolean specialShowInListCondition() {
|
||||
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
return pump == null || pump.getPumpDescription().isTempBasalCapable;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -159,7 +109,7 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!isEnabled(PluginBase.APS)) {
|
||||
if (!isEnabled(PluginType.APS)) {
|
||||
MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.instance().getString(R.string.openapsma_disabled)));
|
||||
if (Config.logAPSResult)
|
||||
log.debug(MainApp.instance().getString(R.string.openapsma_disabled));
|
||||
|
|
|
@ -8,7 +8,6 @@ import java.io.IOException;
|
|||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.GlucoseStatus;
|
||||
|
@ -20,6 +19,8 @@ import info.nightscout.androidaps.db.TemporaryBasal;
|
|||
import info.nightscout.androidaps.interfaces.APSInterface;
|
||||
import info.nightscout.androidaps.interfaces.Constraint;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult;
|
||||
|
@ -33,29 +34,16 @@ import info.nightscout.utils.HardLimits;
|
|||
import info.nightscout.utils.NSUpload;
|
||||
import info.nightscout.utils.Profiler;
|
||||
import info.nightscout.utils.Round;
|
||||
import info.nightscout.utils.SP;
|
||||
import info.nightscout.utils.ToastUtils;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class OpenAPSSMBPlugin implements PluginBase, APSInterface {
|
||||
public class OpenAPSSMBPlugin extends PluginBase implements APSInterface {
|
||||
private static Logger log = LoggerFactory.getLogger(OpenAPSSMBPlugin.class);
|
||||
|
||||
// last values
|
||||
DetermineBasalAdapterSMBJS lastDetermineBasalAdapterSMBJS = null;
|
||||
Date lastAPSRun = null;
|
||||
DetermineBasalResultSMB lastAPSResult = null;
|
||||
AutosensResult lastAutosensResult = null;
|
||||
|
||||
boolean fragmentEnabled = false;
|
||||
boolean fragmentVisible = true;
|
||||
|
||||
private static OpenAPSSMBPlugin openAPSSMBPlugin;
|
||||
|
||||
private OpenAPSSMBPlugin() {
|
||||
}
|
||||
|
||||
public static OpenAPSSMBPlugin getPlugin() {
|
||||
if (openAPSSMBPlugin == null) {
|
||||
openAPSSMBPlugin = new OpenAPSSMBPlugin();
|
||||
|
@ -63,72 +51,32 @@ public class OpenAPSSMBPlugin implements PluginBase, APSInterface {
|
|||
return openAPSSMBPlugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MainApp.instance().getString(R.string.openapssmb);
|
||||
// last values
|
||||
DetermineBasalAdapterSMBJS lastDetermineBasalAdapterSMBJS = null;
|
||||
Date lastAPSRun = null;
|
||||
DetermineBasalResultSMB lastAPSResult = null;
|
||||
AutosensResult lastAutosensResult = null;
|
||||
|
||||
private OpenAPSSMBPlugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.APS)
|
||||
.fragmentClass(OpenAPSSMBFragment.class.getName())
|
||||
.pluginName(R.string.openapssmb)
|
||||
.shortName(R.string.smb_shortname)
|
||||
.preferencesId(R.xml.pref_openapssmb)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameShort() {
|
||||
String name = MainApp.sResources.getString(R.string.smb_shortname);
|
||||
if (!name.trim().isEmpty()) {
|
||||
//only if translation exists
|
||||
return name;
|
||||
}
|
||||
// use long name as fallback
|
||||
return getName();
|
||||
public boolean specialEnableCondition() {
|
||||
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
return pump == null || pump.getPumpDescription().isTempBasalCapable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
boolean pumpCapable = ConfigBuilderPlugin.getActivePump() == null || ConfigBuilderPlugin.getActivePump() != null && ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable;
|
||||
return type == APS && fragmentEnabled && pumpCapable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
boolean pumpCapable = ConfigBuilderPlugin.getActivePump() == null || ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable;
|
||||
return type == APS && fragmentVisible && pumpCapable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFragment() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInList(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == APS) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferencesId() {
|
||||
return R.xml.pref_openapssmb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == APS) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return PluginBase.APS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return OpenAPSSMBFragment.class.getName();
|
||||
public boolean specialShowInListCondition() {
|
||||
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
return pump == null || pump.getPumpDescription().isTempBasalCapable;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -164,7 +112,7 @@ public class OpenAPSSMBPlugin implements PluginBase, APSInterface {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!isEnabled(PluginBase.APS)) {
|
||||
if (!isEnabled(PluginType.APS)) {
|
||||
MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.instance().getString(R.string.openapsma_disabled)));
|
||||
if (Config.logAPSResult)
|
||||
log.debug(MainApp.instance().getString(R.string.openapsma_disabled));
|
||||
|
@ -217,17 +165,20 @@ public class OpenAPSSMBPlugin implements PluginBase, APSInterface {
|
|||
}
|
||||
|
||||
|
||||
if (!checkOnlyHardLimits(profile.getDia(), "dia", HardLimits.MINDIA, HardLimits.MAXDIA)) return;
|
||||
if (!checkOnlyHardLimits(profile.getDia(), "dia", HardLimits.MINDIA, HardLimits.MAXDIA))
|
||||
return;
|
||||
if (!checkOnlyHardLimits(profile.getIcTimeFromMidnight(profile.secondsFromMidnight()), "carbratio", HardLimits.MINIC, HardLimits.MAXIC))
|
||||
return;
|
||||
if (!checkOnlyHardLimits(Profile.toMgdl(profile.getIsf(), units), "sens", HardLimits.MINISF, HardLimits.MAXISF))
|
||||
return;
|
||||
if (!checkOnlyHardLimits(profile.getMaxDailyBasal(), "max_daily_basal", 0.05, HardLimits.maxBasal())) return;
|
||||
if (!checkOnlyHardLimits(pump.getBaseBasalRate(), "current_basal", 0.01, HardLimits.maxBasal())) return;
|
||||
if (!checkOnlyHardLimits(profile.getMaxDailyBasal(), "max_daily_basal", 0.05, HardLimits.maxBasal()))
|
||||
return;
|
||||
if (!checkOnlyHardLimits(pump.getBaseBasalRate(), "current_basal", 0.01, HardLimits.maxBasal()))
|
||||
return;
|
||||
|
||||
startPart = new Date();
|
||||
if (MainApp.getConstraintChecker().isAutosensModeEnabled().value()) {
|
||||
lastAutosensResult = IobCobCalculatorPlugin.getPlugin().detectSensitivityWithLock(IobCobCalculatorPlugin.oldestDataAvailable(), System.currentTimeMillis());
|
||||
lastAutosensResult = IobCobCalculatorPlugin.getPlugin().detectSensitivityWithLock(IobCobCalculatorPlugin.getPlugin().oldestDataAvailable(), System.currentTimeMillis());
|
||||
} else {
|
||||
lastAutosensResult = new AutosensResult();
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ import info.nightscout.androidaps.events.EventRefreshOverview;
|
|||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||
import info.nightscout.androidaps.events.EventTempTargetChange;
|
||||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.interfaces.Constraint;
|
||||
|
@ -112,8 +112,8 @@ import info.nightscout.androidaps.plugins.Overview.events.EventSetWakeLock;
|
|||
import info.nightscout.androidaps.plugins.Overview.graphData.GraphData;
|
||||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||
import info.nightscout.androidaps.plugins.Overview.notifications.NotificationStore;
|
||||
import info.nightscout.androidaps.plugins.SourceDexcomG5.SourceDexcomG5Plugin;
|
||||
import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripPlugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceDexcomG5Plugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceXdripPlugin;
|
||||
import info.nightscout.androidaps.plugins.Treatments.fragments.ProfileViewerDialog;
|
||||
import info.nightscout.androidaps.queue.Callback;
|
||||
import info.nightscout.utils.BolusWizard;
|
||||
|
@ -458,7 +458,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
if (activeloop == null || !MainApp.getConfigBuilder().isProfileValid("ContexMenuCreation"))
|
||||
return;
|
||||
menu.setHeaderTitle(MainApp.sResources.getString(R.string.loop));
|
||||
if (activeloop.isEnabled(PluginBase.LOOP)) {
|
||||
if (activeloop.isEnabled(PluginType.LOOP)) {
|
||||
menu.add(MainApp.sResources.getString(R.string.disableloop));
|
||||
if (!activeloop.isSuspended()) {
|
||||
menu.add(MainApp.sResources.getString(R.string.suspendloopfor1h));
|
||||
|
@ -476,7 +476,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
menu.add(MainApp.sResources.getString(R.string.resume));
|
||||
}
|
||||
}
|
||||
if (!activeloop.isEnabled(PluginBase.LOOP))
|
||||
if (!activeloop.isEnabled(PluginType.LOOP))
|
||||
menu.add(MainApp.sResources.getString(R.string.enableloop));
|
||||
} else if (v == activeProfileView) {
|
||||
menu.setHeaderTitle(MainApp.sResources.getString(R.string.profile));
|
||||
|
@ -494,9 +494,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
return true;
|
||||
final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
|
||||
if (item.getTitle().equals(MainApp.sResources.getString(R.string.disableloop))) {
|
||||
activeloop.setPluginEnabled(PluginBase.LOOP, false);
|
||||
activeloop.setFragmentVisible(PluginBase.LOOP, false);
|
||||
MainApp.getConfigBuilder().storeSettings();
|
||||
activeloop.setPluginEnabled(PluginType.LOOP, false);
|
||||
activeloop.setFragmentVisible(PluginType.LOOP, false);
|
||||
MainApp.getConfigBuilder().storeSettings("DisablingLoop");
|
||||
updateGUI("suspendmenu");
|
||||
MainApp.getConfigBuilder().getCommandQueue().cancelTempBasal(true, new Callback() {
|
||||
@Override
|
||||
|
@ -509,9 +509,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
NSUpload.uploadOpenAPSOffline(24 * 60); // upload 24h, we don't know real duration
|
||||
return true;
|
||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.enableloop))) {
|
||||
activeloop.setPluginEnabled(PluginBase.LOOP, true);
|
||||
activeloop.setFragmentVisible(PluginBase.LOOP, true);
|
||||
MainApp.getConfigBuilder().storeSettings();
|
||||
activeloop.setPluginEnabled(PluginType.LOOP, true);
|
||||
activeloop.setFragmentVisible(PluginType.LOOP, true);
|
||||
MainApp.getConfigBuilder().storeSettings("EnablingLoop");
|
||||
updateGUI("suspendmenu");
|
||||
NSUpload.uploadOpenAPSOffline(0);
|
||||
return true;
|
||||
|
@ -581,8 +581,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
boolean xdrip = MainApp.getSpecificPlugin(SourceXdripPlugin.class) != null && MainApp.getSpecificPlugin(SourceXdripPlugin.class).isEnabled(PluginBase.BGSOURCE);
|
||||
boolean g5 = MainApp.getSpecificPlugin(SourceDexcomG5Plugin.class) != null && MainApp.getSpecificPlugin(SourceDexcomG5Plugin.class).isEnabled(PluginBase.BGSOURCE);
|
||||
boolean xdrip = MainApp.getSpecificPlugin(SourceXdripPlugin.class) != null && MainApp.getSpecificPlugin(SourceXdripPlugin.class).isEnabled(PluginType.BGSOURCE);
|
||||
boolean g5 = MainApp.getSpecificPlugin(SourceDexcomG5Plugin.class) != null && MainApp.getSpecificPlugin(SourceDexcomG5Plugin.class).isEnabled(PluginType.BGSOURCE);
|
||||
String units = MainApp.getConfigBuilder().getProfileUnits();
|
||||
|
||||
FragmentManager manager = getFragmentManager();
|
||||
|
@ -1101,8 +1101,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
}
|
||||
|
||||
// **** Calibration & CGM buttons ****
|
||||
boolean xDripIsBgSource = MainApp.getSpecificPlugin(SourceXdripPlugin.class) != null && MainApp.getSpecificPlugin(SourceXdripPlugin.class).isEnabled(PluginBase.BGSOURCE);
|
||||
boolean g5IsBgSource = MainApp.getSpecificPlugin(SourceDexcomG5Plugin.class) != null && MainApp.getSpecificPlugin(SourceDexcomG5Plugin.class).isEnabled(PluginBase.BGSOURCE);
|
||||
boolean xDripIsBgSource = MainApp.getSpecificPlugin(SourceXdripPlugin.class) != null && MainApp.getSpecificPlugin(SourceXdripPlugin.class).isEnabled(PluginType.BGSOURCE);
|
||||
boolean g5IsBgSource = MainApp.getSpecificPlugin(SourceDexcomG5Plugin.class) != null && MainApp.getSpecificPlugin(SourceDexcomG5Plugin.class).isEnabled(PluginType.BGSOURCE);
|
||||
boolean bgAvailable = DatabaseHelper.actualBg() != null;
|
||||
if (calibrationButton != null) {
|
||||
if ((xDripIsBgSource || g5IsBgSource) && bgAvailable && SP.getBoolean(R.string.key_show_calibration_button, true)) {
|
||||
|
|
|
@ -13,6 +13,8 @@ import info.nightscout.androidaps.data.Profile;
|
|||
import info.nightscout.androidaps.data.QuickWizard;
|
||||
import info.nightscout.androidaps.events.EventRefreshOverview;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||
import info.nightscout.androidaps.plugins.Overview.notifications.NotificationStore;
|
||||
|
@ -21,7 +23,7 @@ import info.nightscout.utils.SP;
|
|||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class OverviewPlugin implements PluginBase {
|
||||
public class OverviewPlugin extends PluginBase {
|
||||
private static Logger log = LoggerFactory.getLogger(OverviewPlugin.class);
|
||||
|
||||
private static OverviewPlugin overviewPlugin = new OverviewPlugin();
|
||||
|
@ -40,82 +42,34 @@ public class OverviewPlugin implements PluginBase {
|
|||
public NotificationStore notificationStore = new NotificationStore();
|
||||
|
||||
public OverviewPlugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.GENERAL)
|
||||
.fragmentClass(OverviewFragment.class.getName())
|
||||
.canBeHidden(false)
|
||||
.alwayVisible(true)
|
||||
.alwaysEnabled(true)
|
||||
.pluginName(R.string.overview)
|
||||
.shortName(R.string.overview_shortname)
|
||||
.preferencesId(R.xml.pref_overview)
|
||||
);
|
||||
String storedData = SP.getString("QuickWizard", "[]");
|
||||
try {
|
||||
quickWizard.setData(new JSONArray(storedData));
|
||||
} catch (JSONException e) {
|
||||
log.error("Unhandled exception", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
MainApp.bus().register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return OverviewFragment.class.getName();
|
||||
protected void onStop() {
|
||||
MainApp.bus().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MainApp.instance().getString(R.string.overview);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameShort() {
|
||||
String name = MainApp.sResources.getString(R.string.overview_shortname);
|
||||
if (!name.trim().isEmpty()) {
|
||||
//only if translation exists
|
||||
return name;
|
||||
}
|
||||
// use long name as fallback
|
||||
return getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return type == GENERAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFragment() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInList(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean fragmentEnabled) {
|
||||
// Always enabled
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
// Always visible
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferencesId() {
|
||||
return R.xml.pref_overview;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return PluginBase.GENERAL;
|
||||
}
|
||||
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventNewNotification n) {
|
||||
notificationStore.add(n.notification);
|
||||
|
@ -128,14 +82,6 @@ public class OverviewPlugin implements PluginBase {
|
|||
MainApp.bus().post(new EventRefreshOverview("EventDismissNotification"));
|
||||
}
|
||||
|
||||
public double determineHighLine() {
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
if (profile == null) {
|
||||
return bgTargetHigh;
|
||||
}
|
||||
return determineHighLine(profile.getUnits());
|
||||
}
|
||||
|
||||
public double determineHighLine(String units) {
|
||||
double highLineSetting = SP.getDouble("high_mark", Profile.fromMgdlToUnits(OverviewPlugin.bgTargetHigh, units));
|
||||
if (highLineSetting < 1)
|
||||
|
|
|
@ -6,8 +6,8 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.support.v4.app.TaskStackBuilder;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.support.v4.app.TaskStackBuilder;
|
||||
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
|
@ -29,6 +29,8 @@ import info.nightscout.androidaps.events.EventRefreshOverview;
|
|||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
|
||||
|
@ -36,84 +38,37 @@ import info.nightscout.utils.DecimalFormatter;
|
|||
* Created by adrian on 23/12/16.
|
||||
*/
|
||||
|
||||
public class PersistentNotificationPlugin implements PluginBase {
|
||||
public class PersistentNotificationPlugin extends PluginBase {
|
||||
|
||||
private static final int ONGOING_NOTIFICATION_ID = 4711;
|
||||
private boolean fragmentEnabled = true;
|
||||
private final Context ctx;
|
||||
|
||||
public PersistentNotificationPlugin(Context ctx) {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.GENERAL)
|
||||
.neverVisible(true)
|
||||
.pluginName(R.string.ongoingnotificaction)
|
||||
.enableByDefault(true)
|
||||
);
|
||||
this.ctx = ctx;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return GENERAL;
|
||||
protected void onStart() {
|
||||
MainApp.bus().register(this);
|
||||
updateNotification();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return ctx.getString(R.string.ongoingnotificaction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameShort() {
|
||||
// use long name as fallback (not visible in tabs)
|
||||
return getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFragment() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInList(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean fragmentEnabled) {
|
||||
if (getType() == type) {
|
||||
this.fragmentEnabled = fragmentEnabled;
|
||||
enableDisableNotification(fragmentEnabled);
|
||||
checkBusRegistration();
|
||||
}
|
||||
}
|
||||
|
||||
private void enableDisableNotification(boolean fragmentEnabled) {
|
||||
if (!fragmentEnabled) {
|
||||
protected void onStop() {
|
||||
MainApp.bus().unregister(this);
|
||||
NotificationManager mNotificationManager =
|
||||
(NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
mNotificationManager.cancel(ONGOING_NOTIFICATION_ID);
|
||||
} else {
|
||||
updateNotification();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateNotification() {
|
||||
if (!fragmentEnabled) {
|
||||
if (!isEnabled(PluginType.GENERAL)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -190,32 +145,6 @@ public class PersistentNotificationPlugin implements PluginBase {
|
|||
|
||||
}
|
||||
|
||||
private void checkBusRegistration() {
|
||||
if (fragmentEnabled) {
|
||||
try {
|
||||
MainApp.bus().register(this);
|
||||
} catch (IllegalArgumentException e) {
|
||||
// already registered
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
MainApp.bus().unregister(this);
|
||||
} catch (IllegalArgumentException e) {
|
||||
// already unregistered
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
//no visible fragment
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferencesId() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
private String deltastring(double deltaMGDL, double deltaMMOL, String units) {
|
||||
String deltastring = "";
|
||||
if (deltaMGDL >= 0) {
|
||||
|
|
|
@ -15,6 +15,8 @@ import info.nightscout.androidaps.MainApp;
|
|||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.ProfileStore;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
import info.nightscout.utils.SP;
|
||||
|
@ -22,7 +24,7 @@ import info.nightscout.utils.SP;
|
|||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class LocalProfilePlugin implements PluginBase, ProfileInterface {
|
||||
public class LocalProfilePlugin extends PluginBase implements ProfileInterface {
|
||||
public static final String LOCAL_PROFILE = "LocalProfile";
|
||||
private static Logger log = LoggerFactory.getLogger(LocalProfilePlugin.class);
|
||||
|
||||
|
@ -34,13 +36,9 @@ public class LocalProfilePlugin implements PluginBase, ProfileInterface {
|
|||
return localProfilePlugin;
|
||||
}
|
||||
|
||||
private boolean fragmentEnabled = false;
|
||||
private boolean fragmentVisible = false;
|
||||
|
||||
private ProfileStore convertedProfile = null;
|
||||
private String convertedProfileName = null;
|
||||
|
||||
public static final String DEFAULTARRAY = "[{\"time\":\"00:00\",\"timeAsSeconds\":0,\"value\":0}]";
|
||||
private static final String DEFAULTARRAY = "[{\"time\":\"00:00\",\"timeAsSeconds\":0,\"value\":0}]";
|
||||
|
||||
boolean mgdl;
|
||||
boolean mmol;
|
||||
|
@ -52,75 +50,15 @@ public class LocalProfilePlugin implements PluginBase, ProfileInterface {
|
|||
JSONArray targetHigh;
|
||||
|
||||
public LocalProfilePlugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.PROFILE)
|
||||
.fragmentClass(LocalProfileFragment.class.getName())
|
||||
.pluginName(R.string.localprofile)
|
||||
.shortName(R.string.localprofile_shortname)
|
||||
);
|
||||
loadSettings();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return LocalProfileFragment.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return PluginBase.PROFILE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MainApp.instance().getString(R.string.localprofile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameShort() {
|
||||
String name = MainApp.sResources.getString(R.string.localprofile_shortname);
|
||||
if (!name.trim().isEmpty()) {
|
||||
//only if translation exists
|
||||
return name;
|
||||
}
|
||||
// use long name as fallback
|
||||
return getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return type == PROFILE && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return type == PROFILE && fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFragment() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInList(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == PROFILE) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == PROFILE) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferencesId() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void storeSettings() {
|
||||
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
||||
SharedPreferences.Editor editor = settings.edit();
|
||||
|
@ -246,7 +184,6 @@ public class LocalProfilePlugin implements PluginBase, ProfileInterface {
|
|||
log.error("Unhandled exception", e);
|
||||
}
|
||||
convertedProfile = new ProfileStore(json);
|
||||
convertedProfileName = LOCAL_PROFILE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,6 +17,8 @@ import info.nightscout.androidaps.R;
|
|||
import info.nightscout.androidaps.Services.Intents;
|
||||
import info.nightscout.androidaps.data.ProfileStore;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||
import info.nightscout.androidaps.plugins.ProfileNS.events.EventNSProfileUpdateGUI;
|
||||
import info.nightscout.utils.SP;
|
||||
|
@ -24,7 +26,7 @@ import info.nightscout.utils.SP;
|
|||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class NSProfilePlugin implements PluginBase, ProfileInterface {
|
||||
public class NSProfilePlugin extends PluginBase implements ProfileInterface {
|
||||
private static Logger log = LoggerFactory.getLogger(NSProfilePlugin.class);
|
||||
|
||||
private static NSProfilePlugin nsProfilePlugin;
|
||||
|
@ -35,83 +37,33 @@ public class NSProfilePlugin implements PluginBase, ProfileInterface {
|
|||
return nsProfilePlugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return NSProfileFragment.class.getName();
|
||||
}
|
||||
|
||||
private boolean fragmentEnabled = true;
|
||||
private boolean fragmentVisible = true;
|
||||
|
||||
private ProfileStore profile = null;
|
||||
|
||||
private NSProfilePlugin() {
|
||||
MainApp.bus().register(this);
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.PROFILE)
|
||||
.fragmentClass(NSProfileFragment.class.getName())
|
||||
.pluginName(R.string.profileviewer)
|
||||
.shortName(R.string.profileviewer_shortname)
|
||||
);
|
||||
loadNSProfile();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MainApp.instance().getString(R.string.profileviewer);
|
||||
protected void onStart() {
|
||||
MainApp.bus().register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameShort() {
|
||||
String name = MainApp.sResources.getString(R.string.profileviewer_shortname);
|
||||
if (!name.trim().isEmpty()) {
|
||||
//only if translation exists
|
||||
return name;
|
||||
}
|
||||
// use long name as fallback
|
||||
return getName();
|
||||
protected void onStop() {
|
||||
MainApp.bus().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return type == PROFILE && (Config.NSCLIENT || Config.G5UPLOADER|| fragmentEnabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return type == PROFILE && (Config.NSCLIENT || Config.G5UPLOADER|| fragmentVisible);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFragment() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInList(int type) {
|
||||
public boolean specialShowInListCondition() {
|
||||
return !Config.NSCLIENT && !Config.G5UPLOADER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == PROFILE) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == PROFILE) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferencesId() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return PluginBase.PROFILE;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void storeNewProfile(ProfileStore newProfile) {
|
||||
profile = new ProfileStore(newProfile.getData());
|
||||
|
|
|
@ -15,13 +15,15 @@ import info.nightscout.androidaps.MainApp;
|
|||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.ProfileStore;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class SimpleProfilePlugin implements PluginBase, ProfileInterface {
|
||||
public class SimpleProfilePlugin extends PluginBase implements ProfileInterface {
|
||||
private static Logger log = LoggerFactory.getLogger(SimpleProfilePlugin.class);
|
||||
|
||||
private static SimpleProfilePlugin simpleProfilePlugin;
|
||||
|
@ -32,9 +34,6 @@ public class SimpleProfilePlugin implements PluginBase, ProfileInterface {
|
|||
return simpleProfilePlugin;
|
||||
}
|
||||
|
||||
private boolean fragmentEnabled = false;
|
||||
private boolean fragmentVisible = false;
|
||||
|
||||
private static ProfileStore convertedProfile = null;
|
||||
|
||||
boolean mgdl;
|
||||
|
@ -47,75 +46,15 @@ public class SimpleProfilePlugin implements PluginBase, ProfileInterface {
|
|||
Double targetHigh;
|
||||
|
||||
private SimpleProfilePlugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.PROFILE)
|
||||
.fragmentClass(SimpleProfileFragment.class.getName())
|
||||
.pluginName(R.string.simpleprofile)
|
||||
.shortName(R.string.simpleprofile_shortname)
|
||||
);
|
||||
loadSettings();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return SimpleProfileFragment.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return PluginBase.PROFILE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MainApp.instance().getString(R.string.simpleprofile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameShort() {
|
||||
String name = MainApp.sResources.getString(R.string.simpleprofile_shortname);
|
||||
if (!name.trim().isEmpty()) {
|
||||
//only if translation exists
|
||||
return name;
|
||||
}
|
||||
// use long name as fallback
|
||||
return getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return type == PROFILE && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return type == PROFILE && fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFragment() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInList(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == PROFILE) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == PROFILE) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferencesId() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void storeSettings() {
|
||||
if (Config.logPrefsChange)
|
||||
log.debug("Storing settings");
|
||||
|
|
|
@ -31,11 +31,13 @@ import info.nightscout.androidaps.db.TemporaryBasal;
|
|||
import info.nightscout.androidaps.db.Treatment;
|
||||
import info.nightscout.androidaps.events.EventInitializationChanged;
|
||||
import info.nightscout.androidaps.events.EventRefreshOverview;
|
||||
import info.nightscout.androidaps.interfaces.Constraint;
|
||||
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.interfaces.Constraint;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||
|
@ -63,14 +65,18 @@ import info.nightscout.utils.SP;
|
|||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterface {
|
||||
public class ComboPlugin extends PluginBase implements PumpInterface, ConstraintsInterface {
|
||||
private static final Logger log = LoggerFactory.getLogger(ComboPlugin.class);
|
||||
public static final String COMBO_TBRS_SET = "combo_tbrs_set";
|
||||
public static final String COMBO_BOLUSES_DELIVERED = "combo_boluses_delivered";
|
||||
|
||||
private static ComboPlugin plugin = null;
|
||||
private boolean fragmentEnabled = false;
|
||||
private boolean fragmentVisible = false;
|
||||
|
||||
public static ComboPlugin getPlugin() {
|
||||
if (plugin == null)
|
||||
plugin = new ComboPlugin();
|
||||
return plugin;
|
||||
}
|
||||
|
||||
private final static PumpDescription pumpDescription = new PumpDescription();
|
||||
|
||||
|
@ -147,16 +153,16 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
|||
*/
|
||||
private volatile List<Bolus> recentBoluses = new ArrayList<>(0);
|
||||
|
||||
public static ComboPlugin getPlugin() {
|
||||
if (plugin == null)
|
||||
plugin = new ComboPlugin();
|
||||
return plugin;
|
||||
}
|
||||
|
||||
private static final PumpEnactResult OPERATION_NOT_SUPPORTED = new PumpEnactResult()
|
||||
.success(false).enacted(false).comment(MainApp.gs(R.string.combo_pump_unsupported_operation));
|
||||
|
||||
private ComboPlugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.PUMP)
|
||||
.fragmentClass(ComboFragment.class.getName())
|
||||
.pluginName(R.string.combopump)
|
||||
.shortName(R.string.combopump_shortname)
|
||||
);
|
||||
ruffyScripter = new RuffyScripter(MainApp.instance().getApplicationContext());
|
||||
}
|
||||
|
||||
|
@ -164,27 +170,6 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
|||
return pump;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return ComboFragment.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MainApp.gs(R.string.combopump);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameShort() {
|
||||
String name = MainApp.gs(R.string.combopump_shortname);
|
||||
if (!name.trim().isEmpty()) {
|
||||
//only if translation exists
|
||||
return name;
|
||||
}
|
||||
// use long name as fallback
|
||||
return getName();
|
||||
}
|
||||
|
||||
String getStateSummary() {
|
||||
PumpState ps = pump.state;
|
||||
if (ps.activeAlert != null) {
|
||||
|
@ -203,53 +188,6 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
|||
return MainApp.gs(R.string.combo_pump_state_running);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
if (type == PluginBase.PUMP) return fragmentEnabled;
|
||||
else if (type == PluginBase.CONSTRAINTS) return fragmentEnabled;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return type == PUMP && fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFragment() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInList(int type) {
|
||||
return type == PUMP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == PUMP) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == PUMP) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferencesId() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return PluginBase.PUMP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInitialized() {
|
||||
return pump.initialized;
|
||||
|
@ -1448,8 +1386,9 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
|||
HashMap<Long, TDD> map = new HashMap<>();
|
||||
for (int i = 0; i < tdds.size(); i++) {
|
||||
Tdd currTdd = tdds.get(i);
|
||||
if(currTdd.total < 1) continue; //cases where dummy days are introduced (e.g. Battery change with date loss)
|
||||
if(map.containsKey(currTdd.timestamp)){
|
||||
if (currTdd.total < 1)
|
||||
continue; //cases where dummy days are introduced (e.g. Battery change with date loss)
|
||||
if (map.containsKey(currTdd.timestamp)) {
|
||||
//duplicate days on time changes
|
||||
TDD existing = map.get(currTdd.timestamp);
|
||||
existing.total += currTdd.total;
|
||||
|
@ -1460,7 +1399,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
|||
|
||||
Collection<TDD> uniqueColl = map.values();
|
||||
|
||||
for (TDD currTdd: uniqueColl) {
|
||||
for (TDD currTdd : uniqueColl) {
|
||||
MainApp.getDbHelper().createOrUpdateTDD(currTdd);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,8 @@ import info.nightscout.androidaps.interfaces.Constraint;
|
|||
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
||||
import info.nightscout.androidaps.interfaces.DanaRInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
|
@ -39,13 +41,9 @@ import info.nightscout.utils.SP;
|
|||
* Created by mike on 28.01.2018.
|
||||
*/
|
||||
|
||||
public abstract class AbstractDanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, ConstraintsInterface, ProfileInterface {
|
||||
public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInterface, DanaRInterface, ConstraintsInterface, ProfileInterface {
|
||||
protected Logger log;
|
||||
|
||||
protected boolean mPluginPumpEnabled = false;
|
||||
protected boolean mPluginProfileEnabled = false;
|
||||
protected boolean mFragmentPumpVisible = true;
|
||||
|
||||
protected AbstractDanaRExecutionService sExecutionService;
|
||||
|
||||
protected DanaRPump pump = DanaRPump.getInstance();
|
||||
|
@ -53,79 +51,26 @@ public abstract class AbstractDanaRPlugin implements PluginBase, PumpInterface,
|
|||
|
||||
public PumpDescription pumpDescription = new PumpDescription();
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return DanaRFragment.class.getName();
|
||||
}
|
||||
|
||||
// Plugin base interface
|
||||
@Override
|
||||
public int getType() {
|
||||
return PluginBase.PUMP;
|
||||
protected AbstractDanaRPlugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.PUMP)
|
||||
.fragmentClass(DanaRFragment.class.getName())
|
||||
.pluginName(R.string.danarspump)
|
||||
.shortName(R.string.danarpump_shortname)
|
||||
.preferencesId(R.xml.pref_danars)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameShort() {
|
||||
String name = MainApp.sResources.getString(R.string.danarpump_shortname);
|
||||
if (!name.trim().isEmpty()) {
|
||||
//only if translation exists
|
||||
return name;
|
||||
}
|
||||
// use long name as fallback
|
||||
return getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
if (type == PluginBase.PROFILE) return mPluginProfileEnabled && mPluginPumpEnabled;
|
||||
else if (type == PluginBase.PUMP) return mPluginPumpEnabled;
|
||||
else if (type == PluginBase.CONSTRAINTS) return mPluginPumpEnabled;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
if (type == PluginBase.PROFILE || type == PluginBase.CONSTRAINTS) return false;
|
||||
else if (type == PluginBase.PUMP) return mFragmentPumpVisible;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFragment() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInList(int type) {
|
||||
return type == PUMP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == PluginBase.PROFILE)
|
||||
mPluginProfileEnabled = fragmentEnabled;
|
||||
else if (type == PluginBase.PUMP)
|
||||
mPluginPumpEnabled = fragmentEnabled;
|
||||
public void onStateChange(PluginType type, State oldState, State newState) {
|
||||
// if pump profile was enabled need to switch to another too
|
||||
if (type == PluginBase.PUMP && !fragmentEnabled && mPluginProfileEnabled) {
|
||||
setPluginEnabled(PluginBase.PROFILE, false);
|
||||
setFragmentVisible(PluginBase.PROFILE, false);
|
||||
NSProfilePlugin.getPlugin().setPluginEnabled(PluginBase.PROFILE, true);
|
||||
NSProfilePlugin.getPlugin().setFragmentVisible(PluginBase.PROFILE, true);
|
||||
if (type == PluginType.PUMP && newState == State.ENABLED && newState == State.DISABLED && isProfileInterfaceEnabled) {
|
||||
setPluginEnabled(PluginType.PROFILE, false);
|
||||
NSProfilePlugin.getPlugin().setPluginEnabled(PluginType.PROFILE, true);
|
||||
NSProfilePlugin.getPlugin().setFragmentVisible(PluginType.PROFILE, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == PluginBase.PUMP)
|
||||
mFragmentPumpVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSuspended() {
|
||||
return pump.pumpSuspended;
|
||||
|
@ -183,7 +128,7 @@ public abstract class AbstractDanaRPlugin implements PluginBase, PumpInterface,
|
|||
int basalIncrement = pump.basal48Enable ? 30 * 60 : 60 * 60;
|
||||
for (int h = 0; h < basalValues; h++) {
|
||||
Double pumpValue = pump.pumpProfiles[pump.activeProfile][h];
|
||||
Double profileValue = profile.getBasalTimeFromMidnight((Integer) (h * basalIncrement));
|
||||
Double profileValue = profile.getBasalTimeFromMidnight(h * basalIncrement);
|
||||
if (profileValue == null) return true;
|
||||
if (Math.abs(pumpValue - profileValue) > getPumpDescription().basalStep) {
|
||||
log.debug("Diff found. Hour: " + h + " Pump: " + pumpValue + " Profile: " + profileValue);
|
||||
|
@ -396,7 +341,7 @@ public abstract class AbstractDanaRPlugin implements PluginBase, PumpInterface,
|
|||
extended.put("BaseBasalRate", getBaseBasalRate());
|
||||
try {
|
||||
extended.put("ActiveProfile", profilename);
|
||||
} catch (Exception e) {
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
pumpjson.put("battery", battery);
|
||||
|
|
|
@ -22,6 +22,7 @@ import info.nightscout.androidaps.db.Treatment;
|
|||
import info.nightscout.androidaps.events.EventAppExit;
|
||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||
import info.nightscout.androidaps.interfaces.Constraint;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.services.DanaRExecutionService;
|
||||
import info.nightscout.utils.Round;
|
||||
|
@ -41,14 +42,10 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
|
|||
}
|
||||
|
||||
public DanaRPlugin() {
|
||||
super();
|
||||
log = LoggerFactory.getLogger(DanaRPlugin.class);
|
||||
useExtendedBoluses = SP.getBoolean("danar_useextended", false);
|
||||
|
||||
Context context = MainApp.instance().getApplicationContext();
|
||||
Intent intent = new Intent(context, DanaRExecutionService.class);
|
||||
context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
|
||||
MainApp.bus().register(this);
|
||||
|
||||
pumpDescription.isBolusCapable = true;
|
||||
pumpDescription.bolusStep = 0.05d;
|
||||
|
||||
|
@ -76,6 +73,22 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
|
|||
pumpDescription.storesCarbInfo = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
Context context = MainApp.instance().getApplicationContext();
|
||||
Intent intent = new Intent(context, DanaRExecutionService.class);
|
||||
context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
|
||||
MainApp.bus().register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
Context context = MainApp.instance().getApplicationContext();
|
||||
context.unbindService(mConnection);
|
||||
|
||||
MainApp.bus().unregister(this);
|
||||
}
|
||||
|
||||
private ServiceConnection mConnection = new ServiceConnection() {
|
||||
|
||||
public void onServiceDisconnected(ComponentName name) {
|
||||
|
@ -98,7 +111,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
|
|||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventPreferenceChange s) {
|
||||
if (isEnabled(PUMP)) {
|
||||
if (isEnabled(PluginType.PUMP)) {
|
||||
boolean previousValue = useExtendedBoluses;
|
||||
useExtendedBoluses = SP.getBoolean("danar_useextended", false);
|
||||
|
||||
|
|
|
@ -1,14 +1,9 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.activities;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.os.IBinder;
|
||||
import android.support.v7.widget.CardView;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
|
@ -32,14 +27,11 @@ import java.util.List;
|
|||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.db.DanaRHistoryRecord;
|
||||
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.interfaces.DanaRInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.services.DanaRExecutionService;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRSyncStatus;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
|
||||
|
@ -124,8 +116,8 @@ public class DanaRHistoryActivity extends Activity {
|
|||
|
||||
statusView.setVisibility(View.GONE);
|
||||
|
||||
boolean isKorean = MainApp.getSpecificPlugin(DanaRKoreanPlugin.class) != null && MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).isEnabled(PluginBase.PUMP);
|
||||
boolean isRS = MainApp.getSpecificPlugin(DanaRSPlugin.class) != null && MainApp.getSpecificPlugin(DanaRSPlugin.class).isEnabled(PluginBase.PUMP);
|
||||
boolean isKorean = MainApp.getSpecificPlugin(DanaRKoreanPlugin.class) != null && MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).isEnabled(PluginType.PUMP);
|
||||
boolean isRS = MainApp.getSpecificPlugin(DanaRSPlugin.class) != null && MainApp.getSpecificPlugin(DanaRSPlugin.class).isEnabled(PluginType.PUMP);
|
||||
|
||||
// Types
|
||||
|
||||
|
|
|
@ -9,10 +9,10 @@ import info.nightscout.androidaps.Config;
|
|||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.events.EventRefreshGui;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
|
||||
|
@ -31,20 +31,20 @@ public class MsgInitConnStatusTime extends MessageBase {
|
|||
MainApp.bus().post(new EventNewNotification(notification));
|
||||
MainApp.getSpecificPlugin(DanaRPlugin.class).disconnect("Wrong Model");
|
||||
log.debug("Wrong model selected. Switching to Korean DanaR");
|
||||
MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setPluginEnabled(PluginBase.PUMP, true);
|
||||
MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setFragmentVisible(PluginBase.PUMP, true);
|
||||
MainApp.getSpecificPlugin(DanaRPlugin.class).setPluginEnabled(PluginBase.PUMP, false);
|
||||
MainApp.getSpecificPlugin(DanaRPlugin.class).setFragmentVisible(PluginBase.PUMP, false);
|
||||
MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setPluginEnabled(PluginType.PUMP, true);
|
||||
MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setFragmentVisible(PluginType.PUMP, true);
|
||||
MainApp.getSpecificPlugin(DanaRPlugin.class).setPluginEnabled(PluginType.PUMP, false);
|
||||
MainApp.getSpecificPlugin(DanaRPlugin.class).setFragmentVisible(PluginType.PUMP, false);
|
||||
|
||||
DanaRPump.reset(); // mark not initialized
|
||||
|
||||
//If profile coming from pump, switch it as well
|
||||
if(MainApp.getSpecificPlugin(DanaRPlugin.class).isEnabled(PluginBase.PROFILE)){
|
||||
(MainApp.getSpecificPlugin(DanaRPlugin.class)).setPluginEnabled(PluginBase.PROFILE, false);
|
||||
(MainApp.getSpecificPlugin(DanaRKoreanPlugin.class)).setPluginEnabled(PluginBase.PROFILE, true);
|
||||
if(MainApp.getSpecificPlugin(DanaRPlugin.class).isEnabled(PluginType.PROFILE)){
|
||||
(MainApp.getSpecificPlugin(DanaRPlugin.class)).setPluginEnabled(PluginType.PROFILE, false);
|
||||
(MainApp.getSpecificPlugin(DanaRKoreanPlugin.class)).setPluginEnabled(PluginType.PROFILE, true);
|
||||
}
|
||||
|
||||
MainApp.getConfigBuilder().storeSettings();
|
||||
MainApp.getConfigBuilder().storeSettings("ChangingDanaDriver");
|
||||
MainApp.bus().post(new EventRefreshGui());
|
||||
ConfigBuilderPlugin.getCommandQueue().readStatus("PumpDriverChange", null); // force new connection
|
||||
return;
|
||||
|
|
|
@ -6,7 +6,7 @@ import org.slf4j.LoggerFactory;
|
|||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||
|
@ -43,7 +43,7 @@ public class MsgSettingMeal extends MessageBase {
|
|||
}
|
||||
|
||||
// DanaRKorean is not possible to set to 0.01 but it works when controlled from AAPS
|
||||
if (DanaRKoreanPlugin.getPlugin().isEnabled(PluginBase.PUMP)) {
|
||||
if (DanaRKoreanPlugin.getPlugin().isEnabled(PluginType.PUMP)) {
|
||||
pump.basalStep = 0.01d;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,9 +22,12 @@ import info.nightscout.androidaps.db.Treatment;
|
|||
import info.nightscout.androidaps.events.EventAppExit;
|
||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||
import info.nightscout.androidaps.interfaces.Constraint;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.AbstractDanaRPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaRKorean.services.DanaRKoreanExecutionService;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaRS.events.EventDanaRSDeviceChange;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaRS.services.DanaRSService;
|
||||
import info.nightscout.utils.Round;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
|
@ -42,14 +45,10 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
|
|||
}
|
||||
|
||||
public DanaRKoreanPlugin() {
|
||||
super();
|
||||
log = LoggerFactory.getLogger(DanaRKoreanPlugin.class);
|
||||
useExtendedBoluses = SP.getBoolean("danar_useextended", false);
|
||||
|
||||
Context context = MainApp.instance().getApplicationContext();
|
||||
Intent intent = new Intent(context, DanaRKoreanExecutionService.class);
|
||||
context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
|
||||
MainApp.bus().register(this);
|
||||
|
||||
pumpDescription.isBolusCapable = true;
|
||||
pumpDescription.bolusStep = 0.1d;
|
||||
|
||||
|
@ -77,6 +76,22 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
|
|||
pumpDescription.storesCarbInfo = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
Context context = MainApp.instance().getApplicationContext();
|
||||
Intent intent = new Intent(context, DanaRKoreanExecutionService.class);
|
||||
context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
|
||||
MainApp.bus().register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
Context context = MainApp.instance().getApplicationContext();
|
||||
context.unbindService(mConnection);
|
||||
|
||||
MainApp.bus().unregister(this);
|
||||
}
|
||||
|
||||
private ServiceConnection mConnection = new ServiceConnection() {
|
||||
|
||||
public void onServiceDisconnected(ComponentName name) {
|
||||
|
@ -99,7 +114,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
|
|||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventPreferenceChange s) {
|
||||
if (isEnabled(PUMP)) {
|
||||
if (isEnabled(PluginType.PUMP)) {
|
||||
boolean previousValue = useExtendedBoluses;
|
||||
useExtendedBoluses = SP.getBoolean("danar_useextended", false);
|
||||
|
||||
|
@ -138,7 +153,8 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
|
|||
Treatment t = new Treatment();
|
||||
t.isSMB = detailedBolusInfo.isSMB;
|
||||
boolean connectionOK = false;
|
||||
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) detailedBolusInfo.carbs, detailedBolusInfo.carbTime, t);
|
||||
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0)
|
||||
connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) detailedBolusInfo.carbs, detailedBolusInfo.carbTime, t);
|
||||
PumpEnactResult result = new PumpEnactResult();
|
||||
result.success = connectionOK;
|
||||
result.bolusDelivered = t.insulin;
|
||||
|
@ -250,7 +266,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
|
|||
// Convert duration from minutes to hours
|
||||
if (Config.logPumpActions)
|
||||
log.debug("setTempBasalAbsolute: Setting temp basal " + percentRate + "% for " + durationInMinutes + " mins (doLowTemp || doHighTemp)");
|
||||
return setTempBasalPercent(percentRate, durationInMinutes, profile,false);
|
||||
return setTempBasalPercent(percentRate, durationInMinutes, profile, false);
|
||||
}
|
||||
if (doExtendedTemp) {
|
||||
// Check if some temp is already in progress
|
||||
|
|
|
@ -9,10 +9,10 @@ import info.nightscout.androidaps.Config;
|
|||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.events.EventRefreshGui;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
|
||||
|
@ -33,20 +33,20 @@ public class MsgInitConnStatusTime_k extends MessageBase {
|
|||
MainApp.bus().post(new EventNewNotification(notification));
|
||||
DanaRKoreanPlugin.getPlugin().disconnect("Wrong Model");
|
||||
log.debug("Wrong model selected. Switching to export DanaR");
|
||||
MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setPluginEnabled(PluginBase.PUMP, false);
|
||||
MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setFragmentVisible(PluginBase.PUMP, false);
|
||||
MainApp.getSpecificPlugin(DanaRPlugin.class).setPluginEnabled(PluginBase.PUMP, true);
|
||||
MainApp.getSpecificPlugin(DanaRPlugin.class).setFragmentVisible(PluginBase.PUMP, true);
|
||||
MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setPluginEnabled(PluginType.PUMP, false);
|
||||
MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setFragmentVisible(PluginType.PUMP, false);
|
||||
MainApp.getSpecificPlugin(DanaRPlugin.class).setPluginEnabled(PluginType.PUMP, true);
|
||||
MainApp.getSpecificPlugin(DanaRPlugin.class).setFragmentVisible(PluginType.PUMP, true);
|
||||
|
||||
DanaRPump.reset(); // mark not initialized
|
||||
|
||||
//If profile coming from pump, switch it as well
|
||||
if (MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).isEnabled(PluginBase.PROFILE)) {
|
||||
(MainApp.getSpecificPlugin(DanaRKoreanPlugin.class)).setPluginEnabled(PluginBase.PROFILE, false);
|
||||
(MainApp.getSpecificPlugin(DanaRPlugin.class)).setPluginEnabled(PluginBase.PROFILE, true);
|
||||
if (MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).isEnabled(PluginType.PROFILE)) {
|
||||
(MainApp.getSpecificPlugin(DanaRKoreanPlugin.class)).setPluginEnabled(PluginType.PROFILE, false);
|
||||
(MainApp.getSpecificPlugin(DanaRPlugin.class)).setPluginEnabled(PluginType.PROFILE, true);
|
||||
}
|
||||
|
||||
MainApp.getConfigBuilder().storeSettings();
|
||||
MainApp.getConfigBuilder().storeSettings("ChangingKoreanDanaDriver");
|
||||
MainApp.bus().post(new EventRefreshGui());
|
||||
ConfigBuilderPlugin.getCommandQueue().readStatus("PumpDriverChange", null); // force new connection
|
||||
return;
|
||||
|
|
|
@ -32,6 +32,8 @@ import info.nightscout.androidaps.interfaces.Constraint;
|
|||
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
||||
import info.nightscout.androidaps.interfaces.DanaRInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
|
@ -54,103 +56,9 @@ import info.nightscout.utils.SP;
|
|||
* Created by mike on 03.09.2017.
|
||||
*/
|
||||
|
||||
public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, ConstraintsInterface, ProfileInterface {
|
||||
public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInterface, ConstraintsInterface, ProfileInterface {
|
||||
private static Logger log = LoggerFactory.getLogger(DanaRSPlugin.class);
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return PluginBase.PUMP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return DanaRFragment.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MainApp.instance().getString(R.string.danarspump);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameShort() {
|
||||
String name = MainApp.sResources.getString(R.string.danarspump_shortname);
|
||||
if (!name.trim().isEmpty()) {
|
||||
//only if translation exists
|
||||
return name;
|
||||
}
|
||||
// use long name as fallback
|
||||
return getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
if (type == PluginBase.PROFILE) return fragmentProfileEnabled && fragmentPumpEnabled;
|
||||
else if (type == PluginBase.PUMP) return fragmentPumpEnabled;
|
||||
else if (type == PluginBase.CONSTRAINTS) return fragmentPumpEnabled;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
if (type == PluginBase.PROFILE || type == PluginBase.CONSTRAINTS) return false;
|
||||
else if (type == PluginBase.PUMP) return fragmentPumpVisible;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFragment() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInList(int type) {
|
||||
return type == PUMP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == PluginBase.PROFILE)
|
||||
this.fragmentProfileEnabled = fragmentEnabled;
|
||||
else if (type == PluginBase.PUMP)
|
||||
this.fragmentPumpEnabled = fragmentEnabled;
|
||||
// if pump profile was enabled need to switch to another too
|
||||
if (type == PluginBase.PUMP && !fragmentEnabled && this.fragmentProfileEnabled) {
|
||||
setPluginEnabled(PluginBase.PROFILE, false);
|
||||
setFragmentVisible(PluginBase.PROFILE, false);
|
||||
MainApp.getSpecificPlugin(NSProfilePlugin.class).setPluginEnabled(PluginBase.PROFILE, true);
|
||||
MainApp.getSpecificPlugin(NSProfilePlugin.class).setFragmentVisible(PluginBase.PROFILE, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == PluginBase.PUMP)
|
||||
this.fragmentPumpVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferencesId() {
|
||||
return R.xml.pref_danars;
|
||||
}
|
||||
|
||||
static boolean fragmentPumpEnabled = false;
|
||||
static boolean fragmentProfileEnabled = false;
|
||||
static boolean fragmentPumpVisible = false;
|
||||
|
||||
public static DanaRSService danaRSService;
|
||||
|
||||
public static String mDeviceAddress = "";
|
||||
public static String mDeviceName = "";
|
||||
|
||||
private static DanaRSPlugin plugin = null;
|
||||
private static DanaRPump pump = DanaRPump.getInstance();
|
||||
public static PumpDescription pumpDescription = new PumpDescription();
|
||||
|
||||
public static DanaRSPlugin getPlugin() {
|
||||
if (plugin == null)
|
||||
|
@ -158,12 +66,22 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
|
|||
return plugin;
|
||||
}
|
||||
|
||||
public static DanaRSService danaRSService;
|
||||
|
||||
public static String mDeviceAddress = "";
|
||||
public static String mDeviceName = "";
|
||||
|
||||
private static DanaRPump pump = DanaRPump.getInstance();
|
||||
public static PumpDescription pumpDescription = new PumpDescription();
|
||||
|
||||
DanaRSPlugin() {
|
||||
Context context = MainApp.instance().getApplicationContext();
|
||||
Intent intent = new Intent(context, DanaRSService.class);
|
||||
context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
|
||||
MainApp.bus().register(this);
|
||||
onStatusEvent(new EventDanaRSDeviceChange()); // load device name
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.PUMP)
|
||||
.fragmentClass(DanaRFragment.class.getName())
|
||||
.pluginName(R.string.danarspump)
|
||||
.shortName(R.string.danarspump_shortname)
|
||||
.preferencesId(R.xml.pref_danars)
|
||||
);
|
||||
|
||||
pumpDescription.isBolusCapable = true;
|
||||
pumpDescription.bolusStep = 0.05d;
|
||||
|
@ -194,6 +112,34 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
|
|||
pumpDescription.storesCarbInfo = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStateChange(PluginType type, State oldState, State newState) {
|
||||
// if pump profile was enabled need to switch to another too
|
||||
if (type == PluginType.PUMP && newState == State.DISABLED && isProfileInterfaceEnabled) {
|
||||
setPluginEnabled(PluginType.PROFILE, false);
|
||||
NSProfilePlugin.getPlugin().setPluginEnabled(PluginType.PROFILE, true);
|
||||
NSProfilePlugin.getPlugin().setFragmentVisible(PluginType.PROFILE, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
Context context = MainApp.instance().getApplicationContext();
|
||||
Intent intent = new Intent(context, DanaRSService.class);
|
||||
context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
|
||||
|
||||
MainApp.bus().register(this);
|
||||
onStatusEvent(new EventDanaRSDeviceChange()); // load device name
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
Context context = MainApp.instance().getApplicationContext();
|
||||
context.unbindService(mConnection);
|
||||
|
||||
MainApp.bus().unregister(this);
|
||||
}
|
||||
|
||||
private ServiceConnection mConnection = new ServiceConnection() {
|
||||
|
||||
public void onServiceDisconnected(ComponentName name) {
|
||||
|
|
|
@ -23,6 +23,8 @@ import info.nightscout.androidaps.interfaces.Constraint;
|
|||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.DetailedBolusInfoStorage;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.AbstractDanaRPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaRS.events.EventDanaRSDeviceChange;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaRS.services.DanaRSService;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaRv2.services.DanaRv2ExecutionService;
|
||||
import info.nightscout.utils.Round;
|
||||
import info.nightscout.utils.SP;
|
||||
|
@ -44,11 +46,6 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
|
|||
log = LoggerFactory.getLogger(DanaRv2Plugin.class);
|
||||
useExtendedBoluses = false;
|
||||
|
||||
Context context = MainApp.instance().getApplicationContext();
|
||||
Intent intent = new Intent(context, DanaRv2ExecutionService.class);
|
||||
context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
|
||||
MainApp.bus().register(this);
|
||||
|
||||
pumpDescription.isBolusCapable = true;
|
||||
pumpDescription.bolusStep = 0.05d;
|
||||
|
||||
|
@ -78,6 +75,23 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
|
|||
pumpDescription.storesCarbInfo = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
Context context = MainApp.instance().getApplicationContext();
|
||||
Intent intent = new Intent(context, DanaRv2ExecutionService.class);
|
||||
context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
|
||||
|
||||
MainApp.bus().register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
Context context = MainApp.instance().getApplicationContext();
|
||||
context.unbindService(mConnection);
|
||||
|
||||
MainApp.bus().unregister(this);
|
||||
}
|
||||
|
||||
private ServiceConnection mConnection = new ServiceConnection() {
|
||||
|
||||
public void onServiceDisconnected(ComponentName name) {
|
||||
|
|
|
@ -7,10 +7,10 @@ import info.nightscout.androidaps.Config;
|
|||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.events.EventRefreshGui;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
|
||||
|
@ -43,20 +43,20 @@ public class MsgCheckValue_v2 extends MessageBase {
|
|||
MainApp.bus().post(new EventNewNotification(notification));
|
||||
MainApp.getSpecificPlugin(DanaRPlugin.class).disconnect("Wrong Model");
|
||||
log.debug("Wrong model selected. Switching to Korean DanaR");
|
||||
MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setPluginEnabled(PluginBase.PUMP, true);
|
||||
MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setFragmentVisible(PluginBase.PUMP, true);
|
||||
MainApp.getSpecificPlugin(DanaRPlugin.class).setPluginEnabled(PluginBase.PUMP, false);
|
||||
MainApp.getSpecificPlugin(DanaRPlugin.class).setFragmentVisible(PluginBase.PUMP, false);
|
||||
MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setPluginEnabled(PluginType.PUMP, true);
|
||||
MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setFragmentVisible(PluginType.PUMP, true);
|
||||
MainApp.getSpecificPlugin(DanaRPlugin.class).setPluginEnabled(PluginType.PUMP, false);
|
||||
MainApp.getSpecificPlugin(DanaRPlugin.class).setFragmentVisible(PluginType.PUMP, false);
|
||||
|
||||
DanaRPump.reset(); // mark not initialized
|
||||
|
||||
//If profile coming from pump, switch it as well
|
||||
if(MainApp.getSpecificPlugin(DanaRPlugin.class).isEnabled(PluginBase.PROFILE)){
|
||||
(MainApp.getSpecificPlugin(DanaRPlugin.class)).setPluginEnabled(PluginBase.PROFILE, false);
|
||||
(MainApp.getSpecificPlugin(DanaRKoreanPlugin.class)).setPluginEnabled(PluginBase.PROFILE, true);
|
||||
if (MainApp.getSpecificPlugin(DanaRPlugin.class).isEnabled(PluginType.PROFILE)) {
|
||||
(MainApp.getSpecificPlugin(DanaRPlugin.class)).setPluginEnabled(PluginType.PROFILE, false);
|
||||
(MainApp.getSpecificPlugin(DanaRKoreanPlugin.class)).setPluginEnabled(PluginType.PROFILE, true);
|
||||
}
|
||||
|
||||
MainApp.getConfigBuilder().storeSettings();
|
||||
MainApp.getConfigBuilder().storeSettings("ChangingDanaRv2Driver");
|
||||
MainApp.bus().post(new EventRefreshGui());
|
||||
ConfigBuilderPlugin.getCommandQueue().readStatus("PumpDriverChange", null); // force new connection
|
||||
return;
|
||||
|
@ -68,18 +68,18 @@ public class MsgCheckValue_v2 extends MessageBase {
|
|||
MainApp.bus().post(new EventNewNotification(notification));
|
||||
DanaRKoreanPlugin.getPlugin().disconnect("Wrong Model");
|
||||
log.debug("Wrong model selected. Switching to non APS DanaR");
|
||||
(MainApp.getSpecificPlugin(DanaRv2Plugin.class)).setPluginEnabled(PluginBase.PUMP, false);
|
||||
(MainApp.getSpecificPlugin(DanaRv2Plugin.class)).setFragmentVisible(PluginBase.PUMP, false);
|
||||
(MainApp.getSpecificPlugin(DanaRPlugin.class)).setPluginEnabled(PluginBase.PUMP, true);
|
||||
(MainApp.getSpecificPlugin(DanaRPlugin.class)).setFragmentVisible(PluginBase.PUMP, true);
|
||||
(MainApp.getSpecificPlugin(DanaRv2Plugin.class)).setPluginEnabled(PluginType.PUMP, false);
|
||||
(MainApp.getSpecificPlugin(DanaRv2Plugin.class)).setFragmentVisible(PluginType.PUMP, false);
|
||||
(MainApp.getSpecificPlugin(DanaRPlugin.class)).setPluginEnabled(PluginType.PUMP, true);
|
||||
(MainApp.getSpecificPlugin(DanaRPlugin.class)).setFragmentVisible(PluginType.PUMP, true);
|
||||
|
||||
//If profile coming from pump, switch it as well
|
||||
if(MainApp.getSpecificPlugin(DanaRv2Plugin.class).isEnabled(PluginBase.PROFILE)){
|
||||
(MainApp.getSpecificPlugin(DanaRv2Plugin.class)).setPluginEnabled(PluginBase.PROFILE, false);
|
||||
(MainApp.getSpecificPlugin(DanaRPlugin.class)).setPluginEnabled(PluginBase.PROFILE, true);
|
||||
if (MainApp.getSpecificPlugin(DanaRv2Plugin.class).isEnabled(PluginType.PROFILE)) {
|
||||
(MainApp.getSpecificPlugin(DanaRv2Plugin.class)).setPluginEnabled(PluginType.PROFILE, false);
|
||||
(MainApp.getSpecificPlugin(DanaRPlugin.class)).setPluginEnabled(PluginType.PROFILE, true);
|
||||
}
|
||||
|
||||
MainApp.getConfigBuilder().storeSettings();
|
||||
MainApp.getConfigBuilder().storeSettings("ChangingDanaRv2Driver");
|
||||
MainApp.bus().post(new EventRefreshGui());
|
||||
ConfigBuilderPlugin.getCommandQueue().readStatus("PumpDriverChange", null); // force new connection
|
||||
return;
|
||||
|
|
|
@ -25,6 +25,8 @@ import info.nightscout.androidaps.db.Treatment;
|
|||
import info.nightscout.androidaps.interfaces.Constraint;
|
||||
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
||||
|
@ -74,21 +76,27 @@ import static info.nightscout.androidaps.plugins.PumpInsight.history.PumpIdCache
|
|||
*/
|
||||
|
||||
@SuppressWarnings("AccessStaticViaInstance")
|
||||
public class InsightPlugin implements PluginBase, PumpInterface, ConstraintsInterface {
|
||||
public class InsightPlugin extends PluginBase implements PumpInterface, ConstraintsInterface {
|
||||
|
||||
private static volatile InsightPlugin plugin;
|
||||
|
||||
public static InsightPlugin getPlugin() {
|
||||
if (plugin == null) {
|
||||
plugin = new InsightPlugin();
|
||||
}
|
||||
return plugin;
|
||||
}
|
||||
|
||||
private static final long BUSY_WAIT_TIME = 20000;
|
||||
static Integer batteryPercent = 0;
|
||||
static Integer reservoirInUnits = 0;
|
||||
static boolean initialized = false;
|
||||
private static Integer batteryPercent = 0;
|
||||
private static Integer reservoirInUnits = 0;
|
||||
private static boolean initialized = false;
|
||||
private static volatile boolean update_pending = false;
|
||||
private static Logger log = LoggerFactory.getLogger(InsightPlugin.class);
|
||||
private static volatile InsightPlugin plugin;
|
||||
private final InsightAsyncAdapter async = new InsightAsyncAdapter();
|
||||
private StatusTaskRunner.Result statusResult;
|
||||
private long statusResultTime = -1;
|
||||
private Date lastDataTime = new Date(0);
|
||||
private boolean fragmentEnabled = false;
|
||||
private boolean fragmentVisible = false;
|
||||
private boolean fauxTBRcancel = true;
|
||||
private PumpDescription pumpDescription = new PumpDescription();
|
||||
private double basalRate = 0;
|
||||
|
@ -97,6 +105,13 @@ public class InsightPlugin implements PluginBase, PumpInterface, ConstraintsInte
|
|||
private List<BRProfileBlock.ProfileBlock> profileBlocks;
|
||||
|
||||
private InsightPlugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.PUMP)
|
||||
.fragmentClass(InsightFragment.class.getName())
|
||||
.pluginName(R.string.insightpump)
|
||||
.shortName(R.string.insightpump_shortname)
|
||||
.preferencesId(R.xml.pref_insightpump)
|
||||
);
|
||||
log("InsightPlugin instantiated");
|
||||
pumpDescription.isBolusCapable = true;
|
||||
pumpDescription.bolusStep = 0.05d; // specification says 0.05U up to 2U then 0.1U @ 2-5U 0.2U @ 10-20U 0.5U 10-20U (are these just UI restrictions?)
|
||||
|
@ -129,20 +144,6 @@ public class InsightPlugin implements PluginBase, PumpInterface, ConstraintsInte
|
|||
}
|
||||
|
||||
|
||||
public static InsightPlugin getPlugin() {
|
||||
if (plugin == null) {
|
||||
createInstance();
|
||||
}
|
||||
return plugin;
|
||||
}
|
||||
|
||||
private static synchronized void createInstance() {
|
||||
if (plugin == null) {
|
||||
log("creating instance");
|
||||
plugin = new InsightPlugin();
|
||||
}
|
||||
}
|
||||
|
||||
// just log during debugging
|
||||
private static void log(String msg) {
|
||||
android.util.Log.e("INSIGHTPUMP", msg);
|
||||
|
@ -157,7 +158,8 @@ public class InsightPlugin implements PluginBase, PumpInterface, ConstraintsInte
|
|||
MainApp.bus().post(e);
|
||||
}
|
||||
|
||||
private void enableConnector() {
|
||||
@Override
|
||||
protected void onStart() {
|
||||
if (!connector_enabled) {
|
||||
synchronized (this) {
|
||||
if (!connector_enabled) {
|
||||
|
@ -170,7 +172,7 @@ public class InsightPlugin implements PluginBase, PumpInterface, ConstraintsInte
|
|||
}
|
||||
}
|
||||
|
||||
private void disableConnector() {
|
||||
protected void onStop() {
|
||||
if (connector_enabled) {
|
||||
synchronized (this) {
|
||||
if (connector_enabled) {
|
||||
|
@ -182,81 +184,6 @@ public class InsightPlugin implements PluginBase, PumpInterface, ConstraintsInte
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return InsightFragment.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MainApp.instance().getString(R.string.insightpump);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameShort() {
|
||||
String name = MainApp.instance().getString(R.string.insightpump_shortname);
|
||||
if (!name.trim().isEmpty()) {
|
||||
//only if translation exists
|
||||
return name;
|
||||
}
|
||||
// use long name as fallback
|
||||
return getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
if (type == PluginBase.PUMP) return fragmentEnabled;
|
||||
else if (type == PluginBase.CONSTRAINTS) return fragmentEnabled;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return type == PUMP && fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFragment() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInList(int type) {
|
||||
return type == PUMP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == PUMP) {
|
||||
if (fragmentEnabled) {
|
||||
enableConnector();
|
||||
} else {
|
||||
disableConnector();
|
||||
}
|
||||
this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == PUMP) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferencesId() {
|
||||
return R.xml.pref_insightpump;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return PluginBase.PUMP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFakingTempsByExtendedBoluses() {
|
||||
return false;
|
||||
|
@ -593,7 +520,6 @@ public class InsightPlugin implements PluginBase, PumpInterface, ConstraintsInte
|
|||
PumpEnactResult pumpEnactResult = new PumpEnactResult().enacted(true).isPercent(true).duration(durationInMinutes);
|
||||
pumpEnactResult.percent = percent_amount;
|
||||
pumpEnactResult.success = ms.success();
|
||||
pumpEnactResult.isTempCancel = percent_amount == 100; // 100% temp basal is a cancellation
|
||||
pumpEnactResult.comment = ms.getCommandComment();
|
||||
|
||||
|
||||
|
@ -644,7 +570,6 @@ public class InsightPlugin implements PluginBase, PumpInterface, ConstraintsInte
|
|||
PumpEnactResult pumpEnactResult = new PumpEnactResult().enacted(true).isPercent(true).duration(durationInMinutes);
|
||||
pumpEnactResult.percent = percent;
|
||||
pumpEnactResult.success = ms.success();
|
||||
pumpEnactResult.isTempCancel = percent == 100; // 100% temp basal is a cancellation
|
||||
pumpEnactResult.comment = ms.getCommandComment();
|
||||
|
||||
if (pumpEnactResult.success) {
|
||||
|
|
|
@ -15,6 +15,8 @@ import info.nightscout.androidaps.data.DetailedBolusInfo;
|
|||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
|
@ -22,14 +24,9 @@ import info.nightscout.utils.DateUtil;
|
|||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class MDIPlugin implements PluginBase, PumpInterface {
|
||||
public class MDIPlugin extends PluginBase implements PumpInterface {
|
||||
private static Logger log = LoggerFactory.getLogger(MDIPlugin.class);
|
||||
|
||||
private boolean fragmentEnabled = false;
|
||||
private boolean fragmentVisible = false;
|
||||
|
||||
private PumpDescription pumpDescription = new PumpDescription();
|
||||
|
||||
private static MDIPlugin plugin = null;
|
||||
|
||||
public static MDIPlugin getPlugin() {
|
||||
|
@ -38,7 +35,13 @@ public class MDIPlugin implements PluginBase, PumpInterface {
|
|||
return plugin;
|
||||
}
|
||||
|
||||
private PumpDescription pumpDescription = new PumpDescription();
|
||||
|
||||
private MDIPlugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.PUMP)
|
||||
.pluginName(R.string.mdi)
|
||||
);
|
||||
pumpDescription.isBolusCapable = true;
|
||||
pumpDescription.bolusStep = 0.5d;
|
||||
|
||||
|
@ -48,67 +51,6 @@ public class MDIPlugin implements PluginBase, PumpInterface {
|
|||
pumpDescription.isRefillingCapable = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MainApp.instance().getString(R.string.mdi);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameShort() {
|
||||
// use long name as fallback (not visible in tabs)
|
||||
return getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return type == PUMP && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFragment() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInList(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == PUMP) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == PUMP) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferencesId() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return PluginBase.PUMP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFakingTempsByExtendedBoluses() {
|
||||
return false;
|
||||
|
|
|
@ -20,6 +20,8 @@ import info.nightscout.androidaps.db.ExtendedBolus;
|
|||
import info.nightscout.androidaps.db.Source;
|
||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||
|
@ -34,19 +36,23 @@ import info.nightscout.utils.SP;
|
|||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class VirtualPumpPlugin implements PluginBase, PumpInterface {
|
||||
public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||
private static Logger log = LoggerFactory.getLogger(VirtualPumpPlugin.class);
|
||||
|
||||
public static Double defaultBasalValue = 0.2d;
|
||||
private static VirtualPumpPlugin plugin = null;
|
||||
|
||||
public static VirtualPumpPlugin getPlugin() {
|
||||
loadFakingStatus();
|
||||
if (plugin == null)
|
||||
plugin = new VirtualPumpPlugin();
|
||||
return plugin;
|
||||
}
|
||||
|
||||
static Integer batteryPercent = 50;
|
||||
static Integer reservoirInUnits = 50;
|
||||
|
||||
private Date lastDataTime = new Date(0);
|
||||
|
||||
private boolean fragmentEnabled = true;
|
||||
private boolean fragmentVisible = true;
|
||||
|
||||
private static boolean fromNSAreCommingFakedExtendedBoluses = false;
|
||||
|
||||
private PumpDescription pumpDescription = new PumpDescription();
|
||||
|
@ -64,16 +70,14 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
|
|||
return fromNSAreCommingFakedExtendedBoluses;
|
||||
}
|
||||
|
||||
private static VirtualPumpPlugin plugin = null;
|
||||
|
||||
public static VirtualPumpPlugin getPlugin() {
|
||||
loadFakingStatus();
|
||||
if (plugin == null)
|
||||
plugin = new VirtualPumpPlugin();
|
||||
return plugin;
|
||||
}
|
||||
|
||||
public VirtualPumpPlugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.PUMP)
|
||||
.fragmentClass(VirtualPumpFragment.class.getName())
|
||||
.pluginName(R.string.virtualpump)
|
||||
.shortName(R.string.virtualpump_shortname)
|
||||
.preferencesId(R.xml.pref_virtualpump)
|
||||
);
|
||||
pumpDescription.isBolusCapable = true;
|
||||
pumpDescription.bolusStep = 0.1d;
|
||||
|
||||
|
@ -104,72 +108,6 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
|
|||
pumpDescription.is30minBasalRatesCapable = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return VirtualPumpFragment.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MainApp.instance().getString(R.string.virtualpump);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameShort() {
|
||||
String name = MainApp.sResources.getString(R.string.virtualpump_shortname);
|
||||
if (!name.trim().isEmpty()) {
|
||||
//only if translation exists
|
||||
return name;
|
||||
}
|
||||
// use long name as fallback
|
||||
return getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return type == PUMP && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return type == PUMP && fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFragment() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInList(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == PUMP) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == PUMP) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferencesId() {
|
||||
return R.xml.pref_virtualpump;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return PluginBase.PUMP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFakingTempsByExtendedBoluses() {
|
||||
return (Config.NSCLIENT || Config.G5UPLOADER) && fromNSAreCommingFakedExtendedBoluses;
|
||||
|
|
|
@ -16,6 +16,8 @@ import info.nightscout.androidaps.MainApp;
|
|||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.SensitivityInterface;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult;
|
||||
|
@ -28,12 +30,9 @@ import info.nightscout.utils.SafeParse;
|
|||
* Created by mike on 24.06.2017.
|
||||
*/
|
||||
|
||||
public class SensitivityAAPSPlugin implements PluginBase, SensitivityInterface{
|
||||
public class SensitivityAAPSPlugin extends PluginBase implements SensitivityInterface{
|
||||
private static Logger log = LoggerFactory.getLogger(SensitivityAAPSPlugin.class);
|
||||
|
||||
private boolean fragmentEnabled = true;
|
||||
private boolean fragmentVisible = false;
|
||||
|
||||
static SensitivityAAPSPlugin plugin = null;
|
||||
|
||||
public static SensitivityAAPSPlugin getPlugin() {
|
||||
|
@ -42,67 +41,15 @@ public class SensitivityAAPSPlugin implements PluginBase, SensitivityInterface{
|
|||
return plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return SENSITIVITY;
|
||||
public SensitivityAAPSPlugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.SENSITIVITY)
|
||||
.pluginName(R.string.sensitivityaaps)
|
||||
.shortName(R.string.sensitivity_shortname)
|
||||
.preferencesId(R.xml.pref_absorption_aaps)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MainApp.sResources.getString(R.string.sensitivityaaps);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameShort() {
|
||||
return MainApp.sResources.getString(R.string.sensitivity_shortname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return type == SENSITIVITY && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return type == SENSITIVITY && fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFragment() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInList(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == SENSITIVITY) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == SENSITIVITY) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferencesId() {
|
||||
return R.xml.pref_absorption_aaps;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AutosensResult detectSensitivity(long fromTime, long toTime) {
|
||||
LongSparseArray<AutosensData> autosensDataTable = IobCobCalculatorPlugin.getPlugin().getAutosensDataTable();
|
||||
|
|
|
@ -15,6 +15,8 @@ import info.nightscout.androidaps.MainApp;
|
|||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.SensitivityInterface;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult;
|
||||
|
@ -27,12 +29,9 @@ import info.nightscout.utils.SafeParse;
|
|||
* Created by mike on 24.06.2017.
|
||||
*/
|
||||
|
||||
public class SensitivityOref0Plugin implements PluginBase, SensitivityInterface {
|
||||
public class SensitivityOref0Plugin extends PluginBase implements SensitivityInterface {
|
||||
private static Logger log = LoggerFactory.getLogger(IobCobCalculatorPlugin.class);
|
||||
|
||||
private boolean fragmentEnabled = true;
|
||||
private boolean fragmentVisible = false;
|
||||
|
||||
static SensitivityOref0Plugin plugin = null;
|
||||
|
||||
public static SensitivityOref0Plugin getPlugin() {
|
||||
|
@ -41,76 +40,24 @@ public class SensitivityOref0Plugin implements PluginBase, SensitivityInterface
|
|||
return plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return SENSITIVITY;
|
||||
public SensitivityOref0Plugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.SENSITIVITY)
|
||||
.pluginName(R.string.sensitivityoref0)
|
||||
.shortName(R.string.sensitivity_shortname)
|
||||
.preferencesId(R.xml.pref_absorption_oref0)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MainApp.sResources.getString(R.string.sensitivityoref0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameShort() {
|
||||
return MainApp.sResources.getString(R.string.sensitivity_shortname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return type == SENSITIVITY && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return type == SENSITIVITY && fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFragment() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInList(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == SENSITIVITY) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == SENSITIVITY) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferencesId() {
|
||||
return R.xml.pref_absorption_oref0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AutosensResult detectSensitivity(long fromTime, long toTime) {
|
||||
LongSparseArray<AutosensData> autosensDataTable = IobCobCalculatorPlugin.getPlugin().getAutosensDataTable();
|
||||
|
||||
String age = SP.getString(R.string.key_age, "");
|
||||
int defaultHours = 24;
|
||||
if (age.equals(MainApp.sResources.getString(R.string.key_adult))) defaultHours = 24;
|
||||
if (age.equals(MainApp.sResources.getString(R.string.key_teenage))) defaultHours = 24;
|
||||
if (age.equals(MainApp.sResources.getString(R.string.key_child))) defaultHours = 24;
|
||||
if (age.equals(MainApp.gs(R.string.key_adult))) defaultHours = 24;
|
||||
if (age.equals(MainApp.gs(R.string.key_teenage))) defaultHours = 24;
|
||||
if (age.equals(MainApp.gs(R.string.key_child))) defaultHours = 24;
|
||||
int hoursForDetection = SP.getInt(R.string.key_openapsama_autosens_period, defaultHours);
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
|
|
|
@ -12,6 +12,8 @@ import info.nightscout.androidaps.MainApp;
|
|||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.SensitivityInterface;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult;
|
||||
|
@ -24,12 +26,9 @@ import info.nightscout.utils.SafeParse;
|
|||
* Created by mike on 24.06.2017.
|
||||
*/
|
||||
|
||||
public class SensitivityWeightedAveragePlugin implements PluginBase, SensitivityInterface {
|
||||
public class SensitivityWeightedAveragePlugin extends PluginBase implements SensitivityInterface {
|
||||
private static Logger log = LoggerFactory.getLogger(SensitivityWeightedAveragePlugin.class);
|
||||
|
||||
private boolean fragmentEnabled = true;
|
||||
private boolean fragmentVisible = false;
|
||||
|
||||
private static SensitivityWeightedAveragePlugin plugin = null;
|
||||
|
||||
public static SensitivityWeightedAveragePlugin getPlugin() {
|
||||
|
@ -38,67 +37,15 @@ public class SensitivityWeightedAveragePlugin implements PluginBase, Sensitivity
|
|||
return plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return SENSITIVITY;
|
||||
public SensitivityWeightedAveragePlugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.SENSITIVITY)
|
||||
.pluginName(R.string.sensitivityweightedaverage)
|
||||
.shortName(R.string.sensitivity_shortname)
|
||||
.preferencesId(R.xml.pref_absorption_aaps)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MainApp.sResources.getString(R.string.sensitivityweightedaverage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameShort() {
|
||||
return MainApp.sResources.getString(R.string.sensitivity_shortname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return type == SENSITIVITY && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return type == SENSITIVITY && fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFragment() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInList(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == SENSITIVITY) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == SENSITIVITY) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferencesId() {
|
||||
return R.xml.pref_absorption_aaps;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AutosensResult detectSensitivity(long fromTime, long toTime) {
|
||||
LongSparseArray<AutosensData> autosensDataTable = IobCobCalculatorPlugin.getPlugin().getAutosensDataTable();
|
||||
|
|
|
@ -31,6 +31,8 @@ import info.nightscout.androidaps.events.EventPreferenceChange;
|
|||
import info.nightscout.androidaps.events.EventRefreshOverview;
|
||||
import info.nightscout.androidaps.interfaces.Constraint;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||
|
@ -49,7 +51,7 @@ import info.nightscout.utils.XdripCalibrations;
|
|||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class SmsCommunicatorPlugin implements PluginBase {
|
||||
public class SmsCommunicatorPlugin extends PluginBase {
|
||||
private static Logger log = LoggerFactory.getLogger(SmsCommunicatorPlugin.class);
|
||||
|
||||
private static SmsCommunicatorPlugin smsCommunicatorPlugin;
|
||||
|
@ -62,11 +64,6 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
|||
return smsCommunicatorPlugin;
|
||||
}
|
||||
|
||||
private boolean fragmentEnabled = false;
|
||||
private boolean fragmentVisible = false;
|
||||
|
||||
private final long CONFIRM_TIMEOUT = 5 * 60 * 1000L;
|
||||
|
||||
private List<String> allowedNumbers = new ArrayList<>();
|
||||
|
||||
class Sms {
|
||||
|
@ -120,74 +117,24 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
|||
ArrayList<Sms> messages = new ArrayList<>();
|
||||
|
||||
private SmsCommunicatorPlugin() {
|
||||
MainApp.bus().register(this);
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.GENERAL)
|
||||
.fragmentClass(SmsCommunicatorFragment.class.getName())
|
||||
.pluginName(R.string.smscommunicator)
|
||||
.shortName(R.string.smscommunicator_shortname)
|
||||
.preferencesId(R.xml.pref_smscommunicator)
|
||||
);
|
||||
processSettings(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return SmsCommunicatorFragment.class.getName();
|
||||
protected void onStart() {
|
||||
MainApp.bus().register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return PluginBase.GENERAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MainApp.sResources.getString(R.string.smscommunicator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameShort() {
|
||||
String name = MainApp.sResources.getString(R.string.smscommunicator_shortname);
|
||||
if (!name.trim().isEmpty()) {
|
||||
//only if translation exists
|
||||
return name;
|
||||
}
|
||||
// use long name as fallback
|
||||
return getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return type == GENERAL && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return type == GENERAL && fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFragment() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInList(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == GENERAL) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == GENERAL) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferencesId() {
|
||||
return R.xml.pref_smscommunicator;
|
||||
protected void onStop() {
|
||||
MainApp.bus().unregister(this);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
@ -217,15 +164,17 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
|||
public void onStatusEvent(final EventNewSMS ev) {
|
||||
|
||||
Object[] pdus = (Object[]) ev.bundle.get("pdus");
|
||||
if (pdus != null) {
|
||||
// For every SMS message received
|
||||
for (Object pdu : pdus) {
|
||||
SmsMessage message = SmsMessage.createFromPdu((byte[]) pdu);
|
||||
processSms(new Sms(message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void processSms(final Sms receivedSms) {
|
||||
if (!isEnabled(PluginBase.GENERAL)) {
|
||||
if (!isEnabled(PluginType.GENERAL)) {
|
||||
log.debug("Ignoring SMS. Plugin disabled.");
|
||||
return;
|
||||
}
|
||||
|
@ -240,10 +189,10 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
|||
log.debug(receivedSms.toString());
|
||||
|
||||
String[] splited = receivedSms.text.split("\\s+");
|
||||
Double amount = 0d;
|
||||
Double tempBasal = 0d;
|
||||
Double amount;
|
||||
Double tempBasal;
|
||||
int duration = 0;
|
||||
String passCode = "";
|
||||
String passCode;
|
||||
boolean remoteCommandsAllowed = SP.getBoolean(R.string.key_smscommunicator_remotecommandsallowed, false);
|
||||
|
||||
if (splited.length > 0) {
|
||||
|
@ -284,8 +233,8 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
|||
case "DISABLE":
|
||||
case "STOP":
|
||||
LoopPlugin loopPlugin = MainApp.getSpecificPlugin(LoopPlugin.class);
|
||||
if (loopPlugin != null && loopPlugin.isEnabled(PluginBase.LOOP)) {
|
||||
loopPlugin.setPluginEnabled(PluginBase.LOOP, false);
|
||||
if (loopPlugin != null && loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||
loopPlugin.setPluginEnabled(PluginType.LOOP, false);
|
||||
ConfigBuilderPlugin.getCommandQueue().cancelTempBasal(true, new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -302,8 +251,8 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
|||
case "ENABLE":
|
||||
case "START":
|
||||
loopPlugin = MainApp.getSpecificPlugin(LoopPlugin.class);
|
||||
if (loopPlugin != null && !loopPlugin.isEnabled(PluginBase.LOOP)) {
|
||||
loopPlugin.setPluginEnabled(PluginBase.LOOP, true);
|
||||
if (loopPlugin != null && !loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||
loopPlugin.setPluginEnabled(PluginType.LOOP, true);
|
||||
reply = MainApp.sResources.getString(R.string.smscommunicator_loophasbeenenabled);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_START"));
|
||||
|
@ -314,7 +263,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
|||
case "STATUS":
|
||||
loopPlugin = MainApp.getSpecificPlugin(LoopPlugin.class);
|
||||
if (loopPlugin != null) {
|
||||
if (loopPlugin.isEnabled(PluginBase.LOOP)) {
|
||||
if (loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||
if (loopPlugin.isSuspended())
|
||||
reply = String.format(MainApp.sResources.getString(R.string.loopsuspendedfor), loopPlugin.minutesToEndOfSuspend());
|
||||
else
|
||||
|
@ -489,7 +438,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
|||
break;
|
||||
default: // expect passCode here
|
||||
if (bolusWaitingForConfirmation != null && !bolusWaitingForConfirmation.processed &&
|
||||
bolusWaitingForConfirmation.confirmCode.equals(splited[0]) && System.currentTimeMillis() - bolusWaitingForConfirmation.date.getTime() < CONFIRM_TIMEOUT) {
|
||||
bolusWaitingForConfirmation.confirmCode.equals(splited[0]) && System.currentTimeMillis() - bolusWaitingForConfirmation.date.getTime() < Constants.SMS_CONFIRM_TIMEOUT) {
|
||||
bolusWaitingForConfirmation.processed = true;
|
||||
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
|
||||
detailedBolusInfo.insulin = bolusWaitingForConfirmation.bolusRequested;
|
||||
|
@ -513,7 +462,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
|||
}
|
||||
});
|
||||
} else if (tempBasalWaitingForConfirmation != null && !tempBasalWaitingForConfirmation.processed &&
|
||||
tempBasalWaitingForConfirmation.confirmCode.equals(splited[0]) && System.currentTimeMillis() - tempBasalWaitingForConfirmation.date.getTime() < CONFIRM_TIMEOUT) {
|
||||
tempBasalWaitingForConfirmation.confirmCode.equals(splited[0]) && System.currentTimeMillis() - tempBasalWaitingForConfirmation.date.getTime() < Constants.SMS_CONFIRM_TIMEOUT) {
|
||||
tempBasalWaitingForConfirmation.processed = true;
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
if (profile != null)
|
||||
|
@ -532,7 +481,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
|||
}
|
||||
});
|
||||
} else if (cancelTempBasalWaitingForConfirmation != null && !cancelTempBasalWaitingForConfirmation.processed &&
|
||||
cancelTempBasalWaitingForConfirmation.confirmCode.equals(splited[0]) && System.currentTimeMillis() - cancelTempBasalWaitingForConfirmation.date.getTime() < CONFIRM_TIMEOUT) {
|
||||
cancelTempBasalWaitingForConfirmation.confirmCode.equals(splited[0]) && System.currentTimeMillis() - cancelTempBasalWaitingForConfirmation.date.getTime() < Constants.SMS_CONFIRM_TIMEOUT) {
|
||||
cancelTempBasalWaitingForConfirmation.processed = true;
|
||||
ConfigBuilderPlugin.getCommandQueue().cancelTempBasal(true, new Callback() {
|
||||
@Override
|
||||
|
@ -549,7 +498,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
|||
}
|
||||
});
|
||||
} else if (calibrationWaitingForConfirmation != null && !calibrationWaitingForConfirmation.processed &&
|
||||
calibrationWaitingForConfirmation.confirmCode.equals(splited[0]) && System.currentTimeMillis() - calibrationWaitingForConfirmation.date.getTime() < CONFIRM_TIMEOUT) {
|
||||
calibrationWaitingForConfirmation.confirmCode.equals(splited[0]) && System.currentTimeMillis() - calibrationWaitingForConfirmation.date.getTime() < Constants.SMS_CONFIRM_TIMEOUT) {
|
||||
calibrationWaitingForConfirmation.processed = true;
|
||||
boolean result = XdripCalibrations.sendIntent(calibrationWaitingForConfirmation.calibrationRequested);
|
||||
if (result) {
|
||||
|
@ -560,7 +509,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
|||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
}
|
||||
} else if (suspendWaitingForConfirmation != null && !suspendWaitingForConfirmation.processed &&
|
||||
suspendWaitingForConfirmation.confirmCode.equals(splited[0]) && System.currentTimeMillis() - suspendWaitingForConfirmation.date.getTime() < CONFIRM_TIMEOUT) {
|
||||
suspendWaitingForConfirmation.confirmCode.equals(splited[0]) && System.currentTimeMillis() - suspendWaitingForConfirmation.date.getTime() < Constants.SMS_CONFIRM_TIMEOUT) {
|
||||
suspendWaitingForConfirmation.processed = true;
|
||||
ConfigBuilderPlugin.getCommandQueue().cancelTempBasal(true, new Callback() {
|
||||
@Override
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps.plugins.SourceDexcomG5;
|
||||
package info.nightscout.androidaps.plugins.Source;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.DialogInterface;
|
||||
|
@ -25,8 +25,6 @@ import info.nightscout.androidaps.data.Profile;
|
|||
import info.nightscout.androidaps.db.BgReading;
|
||||
import info.nightscout.androidaps.events.EventNewBG;
|
||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.FabricPrivacy;
|
||||
import info.nightscout.utils.NSUpload;
|
|
@ -0,0 +1,43 @@
|
|||
package info.nightscout.androidaps.plugins.Source;
|
||||
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
|
||||
/**
|
||||
* Created by mike on 28.11.2017.
|
||||
*/
|
||||
|
||||
public class SourceDexcomG5Plugin extends PluginBase implements BgSourceInterface {
|
||||
|
||||
private static SourceDexcomG5Plugin plugin = null;
|
||||
|
||||
public static SourceDexcomG5Plugin getPlugin() {
|
||||
if (plugin == null)
|
||||
plugin = new SourceDexcomG5Plugin();
|
||||
return plugin;
|
||||
}
|
||||
|
||||
private SourceDexcomG5Plugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.BGSOURCE)
|
||||
.fragmentClass(BGSourceFragment.class.getName())
|
||||
.pluginName(R.string.DexcomG5)
|
||||
.shortName(R.string.dexcomG5_shortname)
|
||||
.preferencesId(R.xml.pref_dexcomg5)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean specialShowInListCondition() {
|
||||
return !Config.G5UPLOADER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean advancedFilteringSupported() {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package info.nightscout.androidaps.plugins.Source;
|
||||
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class SourceGlimpPlugin extends PluginBase implements BgSourceInterface {
|
||||
|
||||
private static SourceGlimpPlugin plugin = null;
|
||||
|
||||
public static SourceGlimpPlugin getPlugin() {
|
||||
if (plugin == null)
|
||||
plugin = new SourceGlimpPlugin();
|
||||
return plugin;
|
||||
}
|
||||
|
||||
private SourceGlimpPlugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.BGSOURCE)
|
||||
.fragmentClass(BGSourceFragment.class.getName())
|
||||
.pluginName(R.string.Glimp)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean advancedFilteringSupported() {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package info.nightscout.androidaps.plugins.Source;
|
||||
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class SourceMM640gPlugin extends PluginBase implements BgSourceInterface {
|
||||
private static SourceMM640gPlugin plugin = null;
|
||||
|
||||
public static SourceMM640gPlugin getPlugin() {
|
||||
if (plugin == null)
|
||||
plugin = new SourceMM640gPlugin();
|
||||
return plugin;
|
||||
}
|
||||
|
||||
private SourceMM640gPlugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.BGSOURCE)
|
||||
.fragmentClass(BGSourceFragment.class.getName())
|
||||
.pluginName(R.string.MM640g)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean advancedFilteringSupported() {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package info.nightscout.androidaps.plugins.Source;
|
||||
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class SourceNSClientPlugin extends PluginBase implements BgSourceInterface {
|
||||
|
||||
private static SourceNSClientPlugin plugin = null;
|
||||
|
||||
public static SourceNSClientPlugin getPlugin() {
|
||||
if (plugin == null)
|
||||
plugin = new SourceNSClientPlugin();
|
||||
return plugin;
|
||||
}
|
||||
|
||||
private SourceNSClientPlugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.BGSOURCE)
|
||||
.fragmentClass(BGSourceFragment.class.getName())
|
||||
.pluginName(R.string.nsclientbg)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean advancedFilteringSupported() {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package info.nightscout.androidaps.plugins.Source;
|
||||
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class SourceXdripPlugin extends PluginBase implements BgSourceInterface {
|
||||
|
||||
private static SourceXdripPlugin plugin = null;
|
||||
|
||||
public static SourceXdripPlugin getPlugin() {
|
||||
if (plugin == null)
|
||||
plugin = new SourceXdripPlugin();
|
||||
return plugin;
|
||||
}
|
||||
|
||||
private SourceXdripPlugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.BGSOURCE)
|
||||
.fragmentClass(BGSourceFragment.class.getName())
|
||||
.pluginName(R.string.xdrip)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean advancedFilteringSupported() {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,89 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.SourceDexcomG5;
|
||||
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
|
||||
/**
|
||||
* Created by mike on 28.11.2017.
|
||||
*/
|
||||
|
||||
public class SourceDexcomG5Plugin implements PluginBase, BgSourceInterface {
|
||||
private boolean fragmentEnabled = false;
|
||||
private boolean fragmentVisible = false;
|
||||
|
||||
private static SourceDexcomG5Plugin plugin = null;
|
||||
|
||||
public static SourceDexcomG5Plugin getPlugin() {
|
||||
if (plugin == null)
|
||||
plugin = new SourceDexcomG5Plugin();
|
||||
return plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return BGSourceFragment.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return PluginBase.BGSOURCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MainApp.instance().getString(R.string.DexcomG5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameShort() {
|
||||
return MainApp.gs(R.string.dexcomG5_shortname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return Config.G5UPLOADER || type == BGSOURCE && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return Config.G5UPLOADER || type == BGSOURCE && fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFragment() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInList(int type) {
|
||||
return !Config.G5UPLOADER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == BGSOURCE) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == BGSOURCE) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferencesId() {
|
||||
return R.xml.pref_dexcomg5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean advancedFilteringSupported() {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,90 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.SourceGlimp;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.plugins.SourceDexcomG5.BGSourceFragment;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class SourceGlimpPlugin implements PluginBase, BgSourceInterface {
|
||||
private boolean fragmentEnabled = false;
|
||||
private boolean fragmentVisible = false;
|
||||
|
||||
private static SourceGlimpPlugin plugin = null;
|
||||
|
||||
public static SourceGlimpPlugin getPlugin() {
|
||||
if (plugin == null)
|
||||
plugin = new SourceGlimpPlugin();
|
||||
return plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return BGSourceFragment.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return PluginBase.BGSOURCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MainApp.instance().getString(R.string.Glimp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameShort() {
|
||||
// use long name as fallback (no tabs)
|
||||
return getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return type == BGSOURCE && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return type == BGSOURCE && fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFragment() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInList(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == BGSOURCE) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == BGSOURCE) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferencesId() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean advancedFilteringSupported() {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,90 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.SourceMM640g;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.plugins.SourceDexcomG5.BGSourceFragment;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class SourceMM640gPlugin implements PluginBase, BgSourceInterface {
|
||||
private boolean fragmentEnabled = false;
|
||||
private boolean fragmentVisible = false;
|
||||
|
||||
private static SourceMM640gPlugin plugin = null;
|
||||
|
||||
public static SourceMM640gPlugin getPlugin() {
|
||||
if (plugin == null)
|
||||
plugin = new SourceMM640gPlugin();
|
||||
return plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return BGSourceFragment.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return PluginBase.BGSOURCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MainApp.instance().getString(R.string.MM640g);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameShort() {
|
||||
// use long name as fallback (no tabs)
|
||||
return getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return type == BGSOURCE && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return type == BGSOURCE && fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFragment() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInList(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == BGSOURCE) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == BGSOURCE) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferencesId() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean advancedFilteringSupported() {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.SourceNSClient;
|
||||
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.plugins.SourceDexcomG5.BGSourceFragment;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class SourceNSClientPlugin implements PluginBase, BgSourceInterface {
|
||||
private boolean fragmentEnabled = true;
|
||||
private boolean fragmentVisible = false;
|
||||
|
||||
private static SourceNSClientPlugin plugin = null;
|
||||
|
||||
public static SourceNSClientPlugin getPlugin() {
|
||||
if (plugin == null)
|
||||
plugin = new SourceNSClientPlugin();
|
||||
return plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return BGSourceFragment.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return PluginBase.BGSOURCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MainApp.instance().getString(R.string.nsclientbg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameShort() {
|
||||
// use long name as fallback (not visible in tabs)
|
||||
return getName();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return Config.NSCLIENT || type == BGSOURCE && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return type == BGSOURCE && fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFragment() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInList(int type) {
|
||||
return !Config.NSCLIENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == BGSOURCE) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == BGSOURCE) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferencesId() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean advancedFilteringSupported() {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,91 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.SourceXdrip;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.plugins.SourceDexcomG5.BGSourceFragment;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class SourceXdripPlugin implements PluginBase, BgSourceInterface {
|
||||
|
||||
private boolean fragmentEnabled = false;
|
||||
private boolean fragmentVisible = false;
|
||||
|
||||
private static SourceXdripPlugin plugin = null;
|
||||
|
||||
public static SourceXdripPlugin getPlugin() {
|
||||
if (plugin == null)
|
||||
plugin = new SourceXdripPlugin();
|
||||
return plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return BGSourceFragment.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return PluginBase.BGSOURCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MainApp.instance().getString(R.string.xdrip);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameShort() {
|
||||
// use long name as fallback (no tabs)
|
||||
return getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return type == BGSOURCE && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return type == BGSOURCE && fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFragment() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInList(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == BGSOURCE) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == BGSOURCE) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferencesId() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean advancedFilteringSupported() {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -34,6 +34,8 @@ import info.nightscout.androidaps.events.EventReloadTempBasalData;
|
|||
import info.nightscout.androidaps.events.EventReloadTreatmentData;
|
||||
import info.nightscout.androidaps.events.EventTempTargetChange;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
|
||||
|
@ -43,7 +45,7 @@ import info.nightscout.utils.SP;
|
|||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
||||
public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface {
|
||||
private static Logger log = LoggerFactory.getLogger(TreatmentsPlugin.class);
|
||||
|
||||
private static TreatmentsPlugin treatmentsPlugin;
|
||||
|
@ -63,76 +65,24 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
|||
private final static Intervals<TempTarget> tempTargets = new OverlappingIntervals<>();
|
||||
private final static ProfileIntervals<ProfileSwitch> profiles = new ProfileIntervals<>();
|
||||
|
||||
private boolean fragmentEnabled = true;
|
||||
private boolean fragmentVisible = true;
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return TreatmentsFragment.class.getName();
|
||||
public TreatmentsPlugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.TREATMENT)
|
||||
.fragmentClass(TreatmentsFragment.class.getName())
|
||||
.pluginName(R.string.treatments)
|
||||
.shortName(R.string.treatments_shortname)
|
||||
.preferencesId(R.xml.pref_absorption_oref0)
|
||||
.alwaysEnabled(true)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MainApp.instance().getString(R.string.treatments);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameShort() {
|
||||
String name = MainApp.sResources.getString(R.string.treatments_shortname);
|
||||
if (!name.trim().isEmpty()) {
|
||||
//only if translation exists
|
||||
return name;
|
||||
}
|
||||
// use long name as fallback
|
||||
return getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return type == TREATMENT && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return type == TREATMENT && fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFragment() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInList(int type) {
|
||||
public boolean specialShowInListCondition() {
|
||||
return !Config.NSCLIENT && !Config.G5UPLOADER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == TREATMENT) this.fragmentEnabled = fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == TREATMENT) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferencesId() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return PluginBase.TREATMENT;
|
||||
}
|
||||
|
||||
private TreatmentsPlugin() {
|
||||
protected void onStart() {
|
||||
MainApp.bus().register(this);
|
||||
initializeTempBasalData();
|
||||
initializeTreatmentData();
|
||||
|
@ -141,6 +91,11 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
|||
initializeProfileSwitchData();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
MainApp.bus().register(this);
|
||||
}
|
||||
|
||||
private static void initializeTreatmentData() {
|
||||
double dia = Constants.defaultDIA;
|
||||
if (MainApp.getConfigBuilder() != null && MainApp.getConfigBuilder().getProfile() != null)
|
||||
|
|
|
@ -5,12 +5,10 @@ import android.content.Intent;
|
|||
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.events.EventBolusRequested;
|
||||
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
||||
import info.nightscout.androidaps.events.EventLoop;
|
||||
import info.nightscout.androidaps.events.EventNewBG;
|
||||
import info.nightscout.androidaps.events.EventNewBasalProfile;
|
||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||
|
@ -18,6 +16,8 @@ import info.nightscout.androidaps.events.EventRefreshOverview;
|
|||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventDismissBolusprogressIfRunning;
|
||||
|
@ -29,7 +29,7 @@ import info.nightscout.utils.SP;
|
|||
* Created by adrian on 17/11/16.
|
||||
*/
|
||||
|
||||
public class WearPlugin implements PluginBase {
|
||||
public class WearPlugin extends PluginBase {
|
||||
|
||||
private static boolean fragmentEnabled = false;
|
||||
private boolean fragmentVisible = false;
|
||||
|
@ -41,6 +41,7 @@ public class WearPlugin implements PluginBase {
|
|||
public static WearPlugin getPlugin() {
|
||||
return wearPlugin;
|
||||
}
|
||||
|
||||
public static WearPlugin initPlugin(Context ctx) {
|
||||
|
||||
if (wearPlugin == null) {
|
||||
|
@ -51,79 +52,27 @@ public class WearPlugin implements PluginBase {
|
|||
}
|
||||
|
||||
WearPlugin(Context ctx) {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.GENERAL)
|
||||
.fragmentClass(WearFragment.class.getName())
|
||||
.pluginName(R.string.wear)
|
||||
.shortName(R.string.wear_shortname)
|
||||
.preferencesId(R.xml.pref_wear)
|
||||
);
|
||||
this.ctx = ctx;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
MainApp.bus().register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return PluginBase.GENERAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return WearFragment.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return ctx.getString(R.string.wear);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameShort() {
|
||||
String name = MainApp.sResources.getString(R.string.wear_shortname);
|
||||
if (!name.trim().isEmpty()){
|
||||
//only if translation exists
|
||||
return name;
|
||||
}
|
||||
// use long name as fallback
|
||||
return getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return type == GENERAL && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return type == GENERAL && fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFragment() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInList(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == GENERAL) {
|
||||
this.fragmentEnabled = fragmentEnabled;
|
||||
if (watchUS != null) {
|
||||
watchUS.setSettings();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == GENERAL) this.fragmentVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferencesId() {
|
||||
return R.xml.pref_wear;
|
||||
protected void onStop() {
|
||||
MainApp.bus().unregister(this);
|
||||
}
|
||||
|
||||
private void sendDataToWatch(boolean status, boolean basals, boolean bgValue) {
|
||||
|
@ -171,7 +120,7 @@ public class WearPlugin implements PluginBase {
|
|||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventOpenAPSUpdateGui ev){
|
||||
public void onStatusEvent(final EventOpenAPSUpdateGui ev) {
|
||||
sendDataToWatch(true, true, false);
|
||||
}
|
||||
|
||||
|
@ -196,7 +145,7 @@ public class WearPlugin implements PluginBase {
|
|||
LoopPlugin activeloop = MainApp.getConfigBuilder().getActiveLoop();
|
||||
if (activeloop == null) return;
|
||||
|
||||
if(WatchUpdaterService.shouldReportLoopStatus(activeloop.isEnabled(PluginBase.LOOP))) {
|
||||
if (WatchUpdaterService.shouldReportLoopStatus(activeloop.isEnabled(PluginType.LOOP))) {
|
||||
sendDataToWatch(true, false, false);
|
||||
}
|
||||
}
|
||||
|
@ -204,7 +153,7 @@ public class WearPlugin implements PluginBase {
|
|||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventOverviewBolusProgress ev) {
|
||||
if(!ev.isSMB()||SP.getBoolean("wear_notifySMB", true)) {
|
||||
if (!ev.isSMB() || SP.getBoolean("wear_notifySMB", true)) {
|
||||
Intent intent = new Intent(ctx, WatchUpdaterService.class).setAction(WatchUpdaterService.ACTION_SEND_BOLUSPROGRESS);
|
||||
intent.putExtra("progresspercent", ev.percent);
|
||||
intent.putExtra("progressstatus", ev.status);
|
||||
|
@ -224,10 +173,10 @@ public class WearPlugin implements PluginBase {
|
|||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventDismissBolusprogressIfRunning ev) {
|
||||
if(ev.result == null) return;
|
||||
if (ev.result == null) return;
|
||||
|
||||
String status;
|
||||
if(ev.result.success){
|
||||
if (ev.result.success) {
|
||||
status = MainApp.sResources.getString(R.string.success);
|
||||
} else {
|
||||
status = MainApp.sResources.getString(R.string.nosuccess);
|
||||
|
@ -238,7 +187,7 @@ public class WearPlugin implements PluginBase {
|
|||
ctx.startService(intent);
|
||||
}
|
||||
|
||||
public void requestActionConfirmation(String title, String message, String actionstring){
|
||||
public void requestActionConfirmation(String title, String message, String actionstring) {
|
||||
|
||||
Intent intent = new Intent(ctx, WatchUpdaterService.class).setAction(WatchUpdaterService.ACTION_SEND_ACTIONCONFIRMATIONREQUEST);
|
||||
intent.putExtra("title", title);
|
||||
|
|
|
@ -21,15 +21,11 @@ import com.google.android.gms.wearable.PutDataRequest;
|
|||
import com.google.android.gms.wearable.Wearable;
|
||||
import com.google.android.gms.wearable.WearableListenerService;
|
||||
|
||||
import org.mozilla.javascript.tools.jsc.Main;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.Constants;
|
||||
|
@ -42,11 +38,11 @@ import info.nightscout.androidaps.db.BgReading;
|
|||
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||
import info.nightscout.androidaps.db.Treatment;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSDeviceStatus;
|
||||
import info.nightscout.androidaps.plugins.Overview.OverviewPlugin;
|
||||
|
@ -290,7 +286,7 @@ public class WatchUpdaterService extends WearableListenerService implements
|
|||
deltastring += DecimalFormatter.to0Decimal(Math.abs(deltaMGDL));
|
||||
}
|
||||
} else {
|
||||
if (detailed){
|
||||
if (detailed) {
|
||||
deltastring += DecimalFormatter.to2Decimal(Math.abs(deltaMMOL));
|
||||
} else {
|
||||
deltastring += DecimalFormatter.to1Decimal(Math.abs(deltaMMOL));
|
||||
|
@ -366,8 +362,6 @@ public class WatchUpdaterService extends WearableListenerService implements
|
|||
ArrayList<DataMap> predictions = new ArrayList<>();
|
||||
|
||||
|
||||
|
||||
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
|
||||
if (profile == null) {
|
||||
|
@ -469,15 +463,15 @@ public class WatchUpdaterService extends WearableListenerService implements
|
|||
}
|
||||
|
||||
List<Treatment> treatments = MainApp.getConfigBuilder().getTreatmentsFromHistory();
|
||||
for (Treatment treatment:treatments) {
|
||||
if(treatment.date > startTimeWindow){
|
||||
for (Treatment treatment : treatments) {
|
||||
if (treatment.date > startTimeWindow) {
|
||||
boluses.add(treatmentMap(treatment.date, treatment.insulin, treatment.carbs, treatment.isSMB, treatment.isValid));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
final LoopPlugin.LastRun finalLastRun = LoopPlugin.lastRun;
|
||||
if(SP.getBoolean("wear_predictions", true) && finalLastRun != null && finalLastRun.request.hasPredictions && finalLastRun.constraintsProcessed != null){
|
||||
if (SP.getBoolean("wear_predictions", true) && finalLastRun != null && finalLastRun.request.hasPredictions && finalLastRun.constraintsProcessed != null) {
|
||||
List<BgReading> predArray = finalLastRun.constraintsProcessed.getPredictions();
|
||||
|
||||
if (!predArray.isEmpty()) {
|
||||
|
@ -587,7 +581,7 @@ public class WatchUpdaterService extends WearableListenerService implements
|
|||
String status = MainApp.instance().getString(R.string.noprofile);
|
||||
String iobSum, iobDetail, cobString, currentBasal, bgiString;
|
||||
iobSum = iobDetail = cobString = currentBasal = bgiString = "";
|
||||
if(profile!=null) {
|
||||
if (profile != null) {
|
||||
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
|
||||
treatmentsInterface.updateTotalIOBTreatments();
|
||||
IobTotal bolusIob = treatmentsInterface.getLastCalculationTreatments().round();
|
||||
|
@ -605,7 +599,7 @@ public class WatchUpdaterService extends WearableListenerService implements
|
|||
double bgi = -(bolusIob.activity + basalIob.activity) * 5 * profile.getIsf();
|
||||
bgiString = "" + ((bgi >= 0) ? "+" : "") + DecimalFormatter.to1Decimal(bgi);
|
||||
|
||||
status = generateStatusString(profile, currentBasal,iobSum, iobDetail, bgiString);
|
||||
status = generateStatusString(profile, currentBasal, iobSum, iobDetail, bgiString);
|
||||
}
|
||||
|
||||
|
||||
|
@ -616,9 +610,9 @@ public class WatchUpdaterService extends WearableListenerService implements
|
|||
|
||||
long openApsStatus = -1;
|
||||
//OpenAPS status
|
||||
if(Config.APS){
|
||||
if (Config.APS) {
|
||||
//we are AndroidAPS
|
||||
openApsStatus = LoopPlugin.lastRun != null && LoopPlugin.lastRun.lastEnact != null && LoopPlugin.lastRun.lastEnact.getTime() != 0 ? LoopPlugin.lastRun.lastEnact.getTime(): -1;
|
||||
openApsStatus = LoopPlugin.lastRun != null && LoopPlugin.lastRun.lastEnact != null && LoopPlugin.lastRun.lastEnact.getTime() != 0 ? LoopPlugin.lastRun.lastEnact.getTime() : -1;
|
||||
} else {
|
||||
//NSClient or remote
|
||||
openApsStatus = NSDeviceStatus.getOpenApsTimestamp();
|
||||
|
@ -673,10 +667,10 @@ public class WatchUpdaterService extends WearableListenerService implements
|
|||
|
||||
LoopPlugin activeloop = MainApp.getConfigBuilder().getActiveLoop();
|
||||
|
||||
if (activeloop != null && !activeloop.isEnabled(PluginBase.LOOP)) {
|
||||
if (activeloop != null && !activeloop.isEnabled(PluginType.LOOP)) {
|
||||
status += getString(R.string.disabledloop) + "\n";
|
||||
lastLoopStatus = false;
|
||||
} else if (activeloop != null && activeloop.isEnabled(PluginBase.LOOP)) {
|
||||
} else if (activeloop != null && activeloop.isEnabled(PluginType.LOOP)) {
|
||||
lastLoopStatus = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@ import info.nightscout.androidaps.events.EventRefreshOverview;
|
|||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||
|
@ -31,19 +33,7 @@ import info.nightscout.utils.DecimalFormatter;
|
|||
* Created by adrian on 17/11/16.
|
||||
*/
|
||||
|
||||
public class StatuslinePlugin implements PluginBase {
|
||||
|
||||
//broadcast related constants
|
||||
private static final String EXTRA_STATUSLINE = "com.eveningoutpost.dexdrip.Extras.Statusline";
|
||||
private static final String ACTION_NEW_EXTERNAL_STATUSLINE = "com.eveningoutpost.dexdrip.ExternalStatusline";
|
||||
private static final String RECEIVER_PERMISSION = "com.eveningoutpost.dexdrip.permissions.RECEIVE_EXTERNAL_STATUSLINE";
|
||||
|
||||
|
||||
private boolean fragmentEnabled = false;
|
||||
private boolean lastLoopStatus;
|
||||
|
||||
private final Context ctx;
|
||||
private SharedPreferences mPrefs;
|
||||
public class StatuslinePlugin extends PluginBase {
|
||||
|
||||
private static StatuslinePlugin statuslinePlugin;
|
||||
|
||||
|
@ -51,8 +41,19 @@ public class StatuslinePlugin implements PluginBase {
|
|||
return statuslinePlugin;
|
||||
}
|
||||
|
||||
public static StatuslinePlugin initPlugin(Context ctx) {
|
||||
//broadcast related constants
|
||||
private static final String EXTRA_STATUSLINE = "com.eveningoutpost.dexdrip.Extras.Statusline";
|
||||
private static final String ACTION_NEW_EXTERNAL_STATUSLINE = "com.eveningoutpost.dexdrip.ExternalStatusline";
|
||||
private static final String RECEIVER_PERMISSION = "com.eveningoutpost.dexdrip.permissions.RECEIVE_EXTERNAL_STATUSLINE";
|
||||
|
||||
|
||||
private boolean lastLoopStatus;
|
||||
|
||||
private final Context ctx;
|
||||
private SharedPreferences mPrefs;
|
||||
|
||||
|
||||
public static StatuslinePlugin initPlugin(Context ctx) {
|
||||
if (statuslinePlugin == null) {
|
||||
statuslinePlugin = new StatuslinePlugin(ctx);
|
||||
}
|
||||
|
@ -60,100 +61,43 @@ public class StatuslinePlugin implements PluginBase {
|
|||
return statuslinePlugin;
|
||||
}
|
||||
|
||||
private StatuslinePlugin(Context ctx) {
|
||||
public StatuslinePlugin(Context ctx) {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.GENERAL)
|
||||
.pluginName(R.string.xdripstatus)
|
||||
.shortName(R.string.xdripstatus_shortname)
|
||||
.neverVisible(true)
|
||||
.preferencesId(R.xml.pref_xdripstatus)
|
||||
);
|
||||
this.ctx = ctx;
|
||||
this.mPrefs = PreferenceManager.getDefaultSharedPreferences(ctx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return PluginBase.GENERAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return ctx.getString(R.string.xdripstatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameShort() {
|
||||
String name = MainApp.sResources.getString(R.string.xdripstatus_shortname);
|
||||
if (!name.trim().isEmpty()) {
|
||||
//only if translation exists
|
||||
return name;
|
||||
}
|
||||
// use long name as fallback
|
||||
return getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return type == GENERAL && fragmentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden(int type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFragment() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInList(int type) {
|
||||
public boolean specialShowInListCondition() {
|
||||
return !Config.NSCLIENT && !Config.G5UPLOADER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == GENERAL) {
|
||||
this.fragmentEnabled = fragmentEnabled;
|
||||
|
||||
if (fragmentEnabled) {
|
||||
try {
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
MainApp.bus().register(this);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
sendStatus();
|
||||
} else {
|
||||
try {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
MainApp.bus().unregister(this);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
sendStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
// do nothing, no gui
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferencesId() {
|
||||
return R.xml.pref_xdripstatus;
|
||||
}
|
||||
|
||||
|
||||
private void sendStatus() {
|
||||
String status = ""; // sent once on disable
|
||||
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
|
||||
if (fragmentEnabled && profile != null) {
|
||||
if (isEnabled(PluginType.GENERAL) && profile != null) {
|
||||
status = buildStatusString(profile);
|
||||
}
|
||||
|
||||
|
@ -171,10 +115,10 @@ public class StatuslinePlugin implements PluginBase {
|
|||
String status = "";
|
||||
LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
|
||||
|
||||
if (activeloop != null && !activeloop.isEnabled(PluginBase.LOOP)) {
|
||||
if (activeloop != null && !activeloop.isEnabled(PluginType.LOOP)) {
|
||||
status += ctx.getString(R.string.disabledloop) + "\n";
|
||||
lastLoopStatus = false;
|
||||
} else if (activeloop != null && activeloop.isEnabled(PluginBase.LOOP)) {
|
||||
} else if (activeloop != null && activeloop.isEnabled(PluginType.LOOP)) {
|
||||
lastLoopStatus = true;
|
||||
}
|
||||
|
||||
|
@ -246,14 +190,9 @@ public class StatuslinePlugin implements PluginBase {
|
|||
LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
|
||||
if (activeloop == null) return;
|
||||
|
||||
if ((lastLoopStatus != activeloop.isEnabled(PluginBase.LOOP))) {
|
||||
if ((lastLoopStatus != activeloop.isEnabled(PluginType.LOOP))) {
|
||||
sendStatus();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean isEnabled() {
|
||||
return fragmentEnabled;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import info.nightscout.androidaps.data.PumpEnactResult;
|
|||
import info.nightscout.androidaps.db.ProfileSwitch;
|
||||
import info.nightscout.androidaps.db.Source;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.SmsCommunicator.SmsCommunicatorPlugin;
|
||||
import info.nightscout.androidaps.queue.Callback;
|
||||
|
@ -34,7 +35,7 @@ public class CommandSetProfile extends Command {
|
|||
ProfileSwitch profileSwitch = MainApp.getConfigBuilder().getProfileSwitchFromHistory(System.currentTimeMillis());
|
||||
if (r.enacted && profileSwitch.source == Source.NIGHTSCOUT) {
|
||||
SmsCommunicatorPlugin smsCommunicatorPlugin = MainApp.getSpecificPlugin(SmsCommunicatorPlugin.class);
|
||||
if (smsCommunicatorPlugin != null && smsCommunicatorPlugin.isEnabled(PluginBase.GENERAL)) {
|
||||
if (smsCommunicatorPlugin != null && smsCommunicatorPlugin.isEnabled(PluginType.GENERAL)) {
|
||||
smsCommunicatorPlugin.sendNotificationToAllNumbers(MainApp.sResources.getString(R.string.profile_set_ok));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import info.nightscout.androidaps.MainActivity;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
|
||||
/**
|
||||
|
@ -37,7 +36,7 @@ public class TabPageAdapter extends FragmentStatePagerAdapter {
|
|||
@Nullable
|
||||
public Fragment getItem(int position) {
|
||||
//Fragment fragment = (Fragment) visibleFragmentList.get(position);
|
||||
return Fragment.instantiate(context, visibleFragmentList.get(position).getFragmentClass());
|
||||
return Fragment.instantiate(context, visibleFragmentList.get(position).pluginDescription.getFragmentClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -67,7 +66,7 @@ public class TabPageAdapter extends FragmentStatePagerAdapter {
|
|||
}
|
||||
|
||||
public void registerNewFragment(PluginBase plugin) {
|
||||
if (plugin.hasFragment() && plugin.isVisibleInTabs(plugin.getType())) {
|
||||
if (plugin.hasFragment() && plugin.isFragmentVisible()) {
|
||||
visibleFragmentList.add(plugin);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context="info.nightscout.androidaps.plugins.SourceDexcomG5.BGSourceFragment">
|
||||
tools:context="info.nightscout.androidaps.plugins.Source.BGSourceFragment">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -586,7 +586,7 @@
|
|||
<string name="careportal_newnstreatment_duration_min_label">Продължителност [мин.]</string>
|
||||
<string name="careportal_pump_label">ПОМПА</string>
|
||||
<string name="date">Дата</string>
|
||||
<string name="dia_too_short" formatted="false">DIA от %s е твърде кратка - използвай %s вместо това!</string>
|
||||
<string name="dia_too_short" formatted="false">DIA от %f е твърде кратка - използвай %f вместо това!</string>
|
||||
<string name="free_peak_oref">Със свободен пик по Oref</string>
|
||||
<string name="insulin_oref_peak">Пик на кривата на IOB</string>
|
||||
<string name="insulin_peak_time">Време на пик [мин.]</string>
|
||||
|
|
|
@ -573,7 +573,7 @@
|
|||
<string name="activate_profile">AKTIVOVAT PROFIL</string>
|
||||
<string name="danar_visualizeextendedaspercentage_title">Zobrazovat prodloužený bolus v %</string>
|
||||
<string name="date">Datum</string>
|
||||
<string name="dia_too_short" formatted="false">DIA %s je příliž krátké - použito %s !</string>
|
||||
<string name="dia_too_short" formatted="false">DIA %f je příliž krátké - použito %f !</string>
|
||||
<string name="insulin_oref_peak">Čas vrcholu IOB křivky</string>
|
||||
<string name="insulin_peak_time">Vrchol křivky [min]</string>
|
||||
<string name="invalid">NEPLATNÝ</string>
|
||||
|
|
|
@ -564,7 +564,7 @@
|
|||
<string name="insulin_peak_time">Peak Time [min]</string>
|
||||
<string name="insulin_oref_peak">IOB Curve Peak Time</string>
|
||||
<string name="free_peak_oref">Free-Peak Oref</string>
|
||||
<string formatted="false" name="dia_too_short">DIA von %s ist zu kurz - AAPS nutzt stattdessen %s!</string>
|
||||
<string formatted="false" name="dia_too_short">DIA von %f ist zu kurz - AAPS nutzt stattdessen %f!</string>
|
||||
<string name="danar_stats_warning_Message">Möglicherweise ungenau, wenn zum Befüllen ein Bolus verwendet wurde!</string>
|
||||
<string name="danar_stats_ratio">Verhältnis</string>
|
||||
<string name="activate_profile">AKTIVIERE PROFIL</string>
|
||||
|
|
|
@ -580,7 +580,7 @@
|
|||
<string name="free_peak_oref">Free-Peak Oref</string>
|
||||
<string name="rapid_acting_oref">Γρήγορη δράση - Oref</string>
|
||||
<string name="ultrarapid_oref">Έξτρα Γρήγορη δράση - Oref</string>
|
||||
<string name="dia_too_short" formatted="false">"DIA για %s πολύ μικρή - χρησιμοποιήστε %s! "</string>
|
||||
<string name="dia_too_short" formatted="false">"DIA για %f πολύ μικρή - χρησιμοποιήστε %f! "</string>
|
||||
<string name="activate_profile">ΕΝΕΡΓΟΠΟΙΗΣΗ ΠΡΟΦΙΛ</string>
|
||||
<string name="date">Ημερομηνία</string>
|
||||
<string name="invalid">ΜΗ ΕΓΚΥΡΟ</string>
|
||||
|
|
|
@ -585,7 +585,7 @@
|
|||
<string name="free_peak_oref">Free-Peak Oref</string>
|
||||
<string name="rapid_acting_oref">Rapid-Acting Oref</string>
|
||||
<string name="ultrarapid_oref">Ultra-Rapid Oref</string>
|
||||
<string name="dia_too_short" formatted="false">DIA de %s demasiado corto - usando %s!</string>
|
||||
<string name="dia_too_short" formatted="false">DIA de %f demasiado corto - usando %f!</string>
|
||||
<string name="activate_profile">ACTIVAR PERFIL</string>
|
||||
<string name="date">Fecha</string>
|
||||
<string name="invalid">INVALIDO</string>
|
||||
|
|
|
@ -579,7 +579,7 @@
|
|||
<string name="insulin_peak_time">"Durée du Pic [min] "</string>
|
||||
<string name="rapid_acting_oref">"Insuline à Action Rapide Oref "</string>
|
||||
<string name="ultrarapid_oref">Insuline à Action Ultra Rapide Oref</string>
|
||||
<string name="dia_too_short" formatted="false">Durée d’Action pour %s trop courte - utiliser %s à la place!</string>
|
||||
<string name="dia_too_short" formatted="false">Durée d’Action pour %f trop courte - utiliser %f à la place!</string>
|
||||
<string name="activate_profile">ACTIVER LE PROFIL</string>
|
||||
<string name="date">" Date"</string>
|
||||
<string name="invalid">INVALID</string>
|
||||
|
|
|
@ -591,7 +591,7 @@
|
|||
<string name="free_peak_oref">Free-Peak Oref</string>
|
||||
<string name="rapid_acting_oref">Rapid-Acting Oref</string>
|
||||
<string name="ultrarapid_oref">Ultra-Rapid Oref</string>
|
||||
<string name="dia_too_short" formatted="false">"DIA %s는 너무 짧습니다. 대신 %s을 사용하세요!"</string>
|
||||
<string name="dia_too_short" formatted="false">"DIA %f는 너무 짧습니다. 대신 %f을 사용하세요!"</string>
|
||||
<string name="activate_profile">프로파일 활성화하기</string>
|
||||
<string name="date">Date</string>
|
||||
<string name="invalid">INVALID</string>
|
||||
|
|
|
@ -587,7 +587,7 @@
|
|||
<string name="activate_profile">Activeer profiel</string>
|
||||
<string name="date">Datum</string>
|
||||
<string name="free_peak_oref">Free-Peak Oref</string>
|
||||
<string name="dia_too_short" formatted="false">DIA van %s te kort - %s wordt inplaats gebruikt!\"</string>
|
||||
<string name="dia_too_short" formatted="false">DIA van %f te kort - %f wordt inplaats gebruikt!\"</string>
|
||||
<string name="insulin_oref_peak">IOB curve piek tijd</string>
|
||||
<string name="insulin_peak_time">Piek tijd [min]</string>
|
||||
<string name="invalid">Ongeldig</string>
|
||||
|
|
|
@ -547,7 +547,7 @@
|
|||
<string name="danar_visualizeextendedaspercentage_title">Просмотреть расширенный болюс %</string>
|
||||
<string name="danarv2pump">DanaRv2</string>
|
||||
<string name="date">дата</string>
|
||||
<string name="dia_too_short" formatted="false">pначение длительности работы инс %s слишком мало - применено %s</string>
|
||||
<string name="dia_too_short" formatted="false">pначение длительности работы инс %f слишком мало - применено %f</string>
|
||||
<string name="extendedbolus">расширенный болюс</string>
|
||||
<string name="free_peak_oref">Акуу-Зуфл Щкуа</string>
|
||||
<string name="hours">час</string>
|
||||
|
|
|
@ -663,7 +663,7 @@
|
|||
<string name="free_peak_oref">Free-Peak Oref</string>
|
||||
<string name="rapid_acting_oref">Rapid-Acting Oref</string>
|
||||
<string name="ultrarapid_oref">Ultra-Rapid Oref</string>
|
||||
<string name="dia_too_short" formatted="false">DIA of %s too short - using %s instead!</string>
|
||||
<string name="dia_too_short" formatted="false">DIA of %f too short - using %f instead!</string>
|
||||
<string name="activate_profile">ACTIVATE PROFILE</string>
|
||||
<string name="date">Date</string>
|
||||
<string name="invalid">INVALID</string>
|
||||
|
@ -994,5 +994,7 @@
|
|||
<string name="record_insulin_cartridge_change">Record insulin cartridge change</string>
|
||||
<string name="smbalwaysdisabled">SMB always and after carbs disabled because active BG source doesn\'t support advanced filtering</string>
|
||||
<string name="smbnotallowedinopenloopmode">SMB not allowed in open loop mode</string>
|
||||
<string name="food_short">Food</string>
|
||||
<string name="iobcobcalculator" translatable="false">IobCobCalculator</string>
|
||||
</resources>
|
||||
|
||||
|
|
|
@ -30,8 +30,8 @@ import static org.mockito.Mockito.when;
|
|||
*/
|
||||
|
||||
public class AAPSMocker {
|
||||
static String validProfile = "{\"dia\":\"3\",\"carbratio\":[{\"time\":\"00:00\",\"value\":\"30\"}],\"carbs_hr\":\"20\",\"delay\":\"20\",\"sens\":[{\"time\":\"00:00\",\"value\":\"100\"},{\"time\":\"2:00\",\"value\":\"110\"}],\"timezone\":\"UTC\",\"basal\":[{\"time\":\"00:00\",\"value\":\"1\"}],\"target_low\":[{\"time\":\"00:00\",\"value\":\"4\"}],\"target_high\":[{\"time\":\"00:00\",\"value\":\"5\"}],\"startDate\":\"1970-01-01T00:00:00.000Z\",\"units\":\"mmol\"}";
|
||||
static Profile profile;
|
||||
private static String validProfile = "{\"dia\":\"3\",\"carbratio\":[{\"time\":\"00:00\",\"value\":\"30\"}],\"carbs_hr\":\"20\",\"delay\":\"20\",\"sens\":[{\"time\":\"00:00\",\"value\":\"100\"},{\"time\":\"2:00\",\"value\":\"110\"}],\"timezone\":\"UTC\",\"basal\":[{\"time\":\"00:00\",\"value\":\"1\"}],\"target_low\":[{\"time\":\"00:00\",\"value\":\"4\"}],\"target_high\":[{\"time\":\"00:00\",\"value\":\"5\"}],\"startDate\":\"1970-01-01T00:00:00.000Z\",\"units\":\"mmol\"}";
|
||||
private static Profile profile;
|
||||
|
||||
public static void mockStrings() {
|
||||
Locale.setDefault(new Locale("en", "US"));
|
||||
|
@ -76,6 +76,8 @@ public class AAPSMocker {
|
|||
when(MainApp.gs(R.string.absolute)).thenReturn("Absolute");
|
||||
when(MainApp.gs(R.string.waitingforpumpresult)).thenReturn("Waiting for result");
|
||||
when(MainApp.gs(R.string.insulin_unit_shortname)).thenReturn("U");
|
||||
when(MainApp.gs(R.string.minimalbasalvaluereplaced)).thenReturn("Basal value replaced by minimal supported value");
|
||||
when(MainApp.gs(R.string.basalprofilenotaligned)).thenReturn("Basal values not aligned to hours: %s");
|
||||
}
|
||||
|
||||
public static MainApp mockMainApp() {
|
||||
|
@ -122,7 +124,34 @@ public class AAPSMocker {
|
|||
try {
|
||||
if (profile == null)
|
||||
profile = new Profile(new JSONObject(validProfile), Constants.MGDL);
|
||||
} catch (JSONException e) {}
|
||||
} catch (JSONException ignored) {}
|
||||
return profile;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import info.nightscout.androidaps.Constants;
|
|||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.interfaces.Constraint;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
|
@ -36,8 +36,8 @@ public class DanaRPluginTest {
|
|||
|
||||
@Test
|
||||
public void basalRateShouldBeLimited() throws Exception {
|
||||
danaRPlugin.setPluginEnabled(PluginBase.PUMP, true);
|
||||
danaRPlugin.setPluginEnabled(PluginBase.PUMP, true);
|
||||
danaRPlugin.setPluginEnabled(PluginType.PUMP, true);
|
||||
danaRPlugin.setPluginEnabled(PluginType.PUMP, true);
|
||||
DanaRPump.getInstance().maxBasal = 0.8d;
|
||||
|
||||
Constraint<Double> c = new Constraint<>(Constants.REALLYHIGHBASALRATE);
|
||||
|
@ -49,8 +49,8 @@ public class DanaRPluginTest {
|
|||
|
||||
@Test
|
||||
public void percentBasalRateShouldBeLimited() throws Exception {
|
||||
danaRPlugin.setPluginEnabled(PluginBase.PUMP, true);
|
||||
danaRPlugin.setPluginEnabled(PluginBase.PUMP, true);
|
||||
danaRPlugin.setPluginEnabled(PluginType.PUMP, true);
|
||||
danaRPlugin.setPluginEnabled(PluginType.PUMP, true);
|
||||
DanaRPump.getInstance().maxBasal = 0.8d;
|
||||
|
||||
Constraint<Integer> c = new Constraint<>(Constants.REALLYHIGHPERCENTBASALRATE);
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.squareup.otto.Bus;
|
|||
import junit.framework.Assert;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
|
@ -16,6 +17,7 @@ import java.util.Calendar;
|
|||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
|
@ -44,12 +46,8 @@ public class ProfileTest {
|
|||
|
||||
//String profileStore = "{\"defaultProfile\":\"Default\",\"store\":{\"Default\":" + validProfile + "}}";
|
||||
|
||||
boolean notificationSent = false;
|
||||
|
||||
@Test
|
||||
public void doTests() throws Exception {
|
||||
prepareMock();
|
||||
|
||||
Profile p = new Profile();
|
||||
|
||||
// Test valid profile
|
||||
|
@ -105,7 +103,7 @@ public class ProfileTest {
|
|||
//Test basal profile below limit
|
||||
p = new Profile(new JSONObject(belowLimitValidProfile), 100, 0);
|
||||
p.isValid("Test");
|
||||
Assert.assertEquals(true, notificationSent);
|
||||
Assert.assertEquals(true, ((AAPSMocker.MockedBus) MainApp.bus()).notificationSent);
|
||||
|
||||
// Test profile w/o units
|
||||
p = new Profile(new JSONObject(noUnitsValidProfile), 100, 0);
|
||||
|
@ -140,37 +138,24 @@ public class ProfileTest {
|
|||
|
||||
// Test hour alignment
|
||||
MainApp.getConfigBuilder().getActivePump().getPumpDescription().is30minBasalRatesCapable = false;
|
||||
notificationSent = false;
|
||||
((AAPSMocker.MockedBus) MainApp.bus()).notificationSent = false;
|
||||
p = new Profile(new JSONObject(notAllignedBasalValidProfile), 100, 0);
|
||||
p.isValid("Test");
|
||||
Assert.assertEquals(true, notificationSent);
|
||||
Assert.assertEquals(true, ((AAPSMocker.MockedBus) MainApp.bus()).notificationSent);
|
||||
}
|
||||
|
||||
private void prepareMock() throws Exception {
|
||||
Locale.setDefault(new Locale("en", "US"));
|
||||
ConfigBuilderPlugin configBuilderPlugin = mock(ConfigBuilderPlugin.class);
|
||||
PowerMockito.mockStatic(ConfigBuilderPlugin.class);
|
||||
@Before
|
||||
public void prepareMock() throws Exception {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockConfigBuilder();
|
||||
AAPSMocker.mockStrings();
|
||||
AAPSMocker.prepareMockedBus();
|
||||
|
||||
MainApp mainApp = mock(MainApp.class);
|
||||
PowerMockito.mockStatic(MainApp.class);
|
||||
when(MainApp.instance()).thenReturn(mainApp);
|
||||
when(MainApp.getConfigBuilder()).thenReturn(configBuilderPlugin);
|
||||
when(MainApp.getConfigBuilder().getActivePump()).thenReturn(pump);
|
||||
when(MainApp.gs(R.string.minimalbasalvaluereplaced)).thenReturn("AnyString");
|
||||
when(MainApp.gs(R.string.basalprofilenotaligned)).thenReturn("AnyString");
|
||||
|
||||
PowerMockito.mockStatic(FabricPrivacy.class);
|
||||
// PowerMockito.doNothing().when(FabricPrivacy.log(""));
|
||||
|
||||
MockedBus bus = new MockedBus();
|
||||
when(MainApp.bus()).thenReturn(bus);
|
||||
}
|
||||
|
||||
class MockedBus extends Bus {
|
||||
@Override
|
||||
public void post(Object event) {
|
||||
notificationSent = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ import info.nightscout.androidaps.plugins.PumpDanaRS.DanaRSPlugin;
|
|||
import info.nightscout.androidaps.plugins.PumpInsight.InsightPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpInsight.connector.StatusTaskRunner;
|
||||
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
|
||||
import info.nightscout.androidaps.plugins.SourceGlimp.SourceGlimpPlugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceGlimpPlugin;
|
||||
import info.nightscout.utils.FabricPrivacy;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
|
@ -64,7 +64,7 @@ public class ConstraintsCheckerTest {
|
|||
|
||||
@Test
|
||||
public void isLoopInvokationAllowedTest() throws Exception {
|
||||
comboPlugin.setPluginEnabled(PluginBase.PUMP, true);
|
||||
comboPlugin.setPluginEnabled(PluginType.PUMP, true);
|
||||
comboPlugin.setValidBasalRateProfileSelectedOnPump(false);
|
||||
|
||||
Constraint<Boolean> c = constraintChecker.isLoopInvokationAllowed();
|
||||
|
@ -137,12 +137,12 @@ public class ConstraintsCheckerTest {
|
|||
@Test
|
||||
public void basalRateShouldBeLimited() throws Exception {
|
||||
// DanaR, RS
|
||||
danaRPlugin.setPluginEnabled(PluginBase.PUMP, true);
|
||||
danaRSPlugin.setPluginEnabled(PluginBase.PUMP, true);
|
||||
danaRPlugin.setPluginEnabled(PluginType.PUMP, true);
|
||||
danaRSPlugin.setPluginEnabled(PluginType.PUMP, true);
|
||||
DanaRPump.getInstance().maxBasal = 0.8d;
|
||||
|
||||
// Insight
|
||||
insightPlugin.setPluginEnabled(PluginBase.PUMP, true);
|
||||
insightPlugin.setPluginEnabled(PluginType.PUMP, true);
|
||||
StatusTaskRunner.Result result = new StatusTaskRunner.Result();
|
||||
result.maximumBasalAmount = 1.1d;
|
||||
insightPlugin.setStatusResult(result);
|
||||
|
@ -164,12 +164,12 @@ public class ConstraintsCheckerTest {
|
|||
@Test
|
||||
public void percentBasalRateShouldBeLimited() throws Exception {
|
||||
// DanaR, RS
|
||||
danaRPlugin.setPluginEnabled(PluginBase.PUMP, true);
|
||||
danaRSPlugin.setPluginEnabled(PluginBase.PUMP, true);
|
||||
danaRPlugin.setPluginEnabled(PluginType.PUMP, true);
|
||||
danaRSPlugin.setPluginEnabled(PluginType.PUMP, true);
|
||||
DanaRPump.getInstance().maxBasal = 0.8d;
|
||||
|
||||
// Insight
|
||||
insightPlugin.setPluginEnabled(PluginBase.PUMP, true);
|
||||
insightPlugin.setPluginEnabled(PluginType.PUMP, true);
|
||||
StatusTaskRunner.Result result = new StatusTaskRunner.Result();
|
||||
result.maximumBasalAmount = 1.1d;
|
||||
insightPlugin.setStatusResult(result);
|
||||
|
@ -192,12 +192,12 @@ public class ConstraintsCheckerTest {
|
|||
@Test
|
||||
public void bolusAmountShouldBeLimited() throws Exception {
|
||||
// DanaR, RS
|
||||
danaRPlugin.setPluginEnabled(PluginBase.PUMP, true);
|
||||
danaRSPlugin.setPluginEnabled(PluginBase.PUMP, true);
|
||||
danaRPlugin.setPluginEnabled(PluginType.PUMP, true);
|
||||
danaRSPlugin.setPluginEnabled(PluginType.PUMP, true);
|
||||
DanaRPump.getInstance().maxBolus = 6d;
|
||||
|
||||
// Insight
|
||||
insightPlugin.setPluginEnabled(PluginBase.PUMP, true);
|
||||
insightPlugin.setPluginEnabled(PluginType.PUMP, true);
|
||||
StatusTaskRunner.Result result = new StatusTaskRunner.Result();
|
||||
result.maximumBolusAmount = 7d;
|
||||
insightPlugin.setStatusResult(result);
|
||||
|
@ -233,9 +233,9 @@ public class ConstraintsCheckerTest {
|
|||
// No limit by default
|
||||
when(SP.getDouble(R.string.key_openapsma_max_iob, 1.5d)).thenReturn(1.5d);
|
||||
when(SP.getString(R.string.key_age, "")).thenReturn("teenage");
|
||||
OpenAPSMAPlugin.getPlugin().setPluginEnabled(PluginBase.APS, true);
|
||||
OpenAPSAMAPlugin.getPlugin().setPluginEnabled(PluginBase.APS, true);
|
||||
OpenAPSSMBPlugin.getPlugin().setPluginEnabled(PluginBase.APS, true);
|
||||
OpenAPSMAPlugin.getPlugin().setPluginEnabled(PluginType.APS, true);
|
||||
OpenAPSAMAPlugin.getPlugin().setPluginEnabled(PluginType.APS, true);
|
||||
OpenAPSSMBPlugin.getPlugin().setPluginEnabled(PluginType.APS, true);
|
||||
|
||||
// Apply all limits
|
||||
Constraint<Double> d = constraintChecker.getMaxIOBAllowed();
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
package info.nightscout.androidaps.interfaces;
|
||||
|
||||
import net.bytebuddy.build.Plugin;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.nightscout.androidaps.plugins.ProfileNS.NSProfileFragment;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
public class PluginDescriptionTest {
|
||||
|
||||
@Test
|
||||
public void mainTypeTest() {
|
||||
PluginDescription pluginDescription = new PluginDescription().mainType(PluginType.PUMP);
|
||||
Assert.assertEquals(PluginType.PUMP, pluginDescription.getType());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fragmentClassTest() {
|
||||
PluginDescription pluginDescription = new PluginDescription().fragmentClass(NSProfileFragment.class.getName());
|
||||
Assert.assertEquals(NSProfileFragment.class.getName(), pluginDescription.getFragmentClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canBeHiddenTest() {
|
||||
PluginDescription pluginDescription = new PluginDescription().canBeHidden(false);
|
||||
Assert.assertEquals(false, pluginDescription.canBeHidden);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void alwaysEnabledTest() {
|
||||
PluginDescription pluginDescription = new PluginDescription().alwaysEnabled(true);
|
||||
Assert.assertEquals(true, pluginDescription.alwaysEnabled);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void alwayVisibleTest() {
|
||||
PluginDescription pluginDescription = new PluginDescription().alwayVisible(true);
|
||||
Assert.assertEquals(true, pluginDescription.alwayVisible);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void neverVisibleTest() {
|
||||
PluginDescription pluginDescription = new PluginDescription().neverVisible(true);
|
||||
Assert.assertEquals(true, pluginDescription.neverVisible);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void showInListTest() {
|
||||
PluginDescription pluginDescription = new PluginDescription().showInList(false);
|
||||
Assert.assertEquals(false, pluginDescription.showInList);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pluginName() {
|
||||
PluginDescription pluginDescription = new PluginDescription().pluginName(10);
|
||||
Assert.assertEquals(10, pluginDescription.pluginName);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shortNameTest() {
|
||||
PluginDescription pluginDescription = new PluginDescription().shortName(10);
|
||||
Assert.assertEquals(10, pluginDescription.shortName);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void preferencesIdTest() {
|
||||
PluginDescription pluginDescription = new PluginDescription().preferencesId(10);
|
||||
Assert.assertEquals(10, pluginDescription.preferencesId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void advancedPreferencesIdTest() {
|
||||
PluginDescription pluginDescription = new PluginDescription().advancedPreferencesId(10);
|
||||
Assert.assertEquals(10, pluginDescription.advancedPreferencesId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void enableByDefault() {
|
||||
PluginDescription pluginDescription = new PluginDescription().enableByDefault(true);
|
||||
Assert.assertEquals(true, pluginDescription.enableByDefault);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void visibleByDefault() {
|
||||
PluginDescription pluginDescription = new PluginDescription().visibleByDefault(true);
|
||||
Assert.assertEquals(true, pluginDescription.visibleByDefault);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package info.nightscout.androidaps.plugins.ConfigBuilder;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
|
||||
import static org.powermock.api.mockito.PowerMockito.mock;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class})
|
||||
public class ConfigBuilderPluginTest {
|
||||
|
||||
@Test
|
||||
public void getPluginTest() {
|
||||
ConfigBuilderPlugin configBuilderPlugin = ConfigBuilderPlugin.getPlugin();
|
||||
Assert.assertNotNull(configBuilderPlugin);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onStartTest() {
|
||||
ConfigBuilderPlugin configBuilderPlugin = ConfigBuilderPlugin.getPlugin();
|
||||
configBuilderPlugin.setPluginEnabled(PluginType.GENERAL, true);
|
||||
Assert.assertEquals(true, ((AAPSMocker.MockedBus) MainApp.bus()).registered);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onStopTest() {
|
||||
ConfigBuilderPlugin configBuilderPlugin = ConfigBuilderPlugin.getPlugin();
|
||||
configBuilderPlugin.setPluginEnabled(PluginType.GENERAL, true);
|
||||
configBuilderPlugin.setPluginEnabled(PluginType.GENERAL, false);
|
||||
Assert.assertEquals(false, ((AAPSMocker.MockedBus) MainApp.bus()).registered);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void prepareMock() throws Exception {
|
||||
MainApp mainApp = mock(MainApp.class);
|
||||
PowerMockito.mockStatic(MainApp.class);
|
||||
AAPSMocker.prepareMockedBus();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -13,6 +13,7 @@ import java.util.Date;
|
|||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.interfaces.Constraint;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
|
|
|
@ -15,13 +15,13 @@ import info.nightscout.androidaps.Constants;
|
|||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.interfaces.Constraint;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSMA.OpenAPSMAPlugin;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSSMB.OpenAPSSMBPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
|
||||
import info.nightscout.androidaps.plugins.SourceGlimp.SourceGlimpPlugin;
|
||||
import info.nightscout.androidaps.plugins.Source.SourceGlimpPlugin;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.mockito.Mockito.when;
|
||||
|
@ -208,9 +208,9 @@ public class SafetyPluginTest {
|
|||
public void iobShouldBeLimited() throws Exception {
|
||||
when(SP.getDouble(R.string.key_openapsma_max_iob, 1.5d)).thenReturn(1.5d);
|
||||
when(SP.getString(R.string.key_age, "")).thenReturn("teenage");
|
||||
OpenAPSMAPlugin.getPlugin().setPluginEnabled(PluginBase.APS, true);
|
||||
OpenAPSAMAPlugin.getPlugin().setPluginEnabled(PluginBase.APS, true);
|
||||
OpenAPSSMBPlugin.getPlugin().setPluginEnabled(PluginBase.APS, true);
|
||||
OpenAPSMAPlugin.getPlugin().setPluginEnabled(PluginType.APS, true);
|
||||
OpenAPSAMAPlugin.getPlugin().setPluginEnabled(PluginType.APS, true);
|
||||
OpenAPSSMBPlugin.getPlugin().setPluginEnabled(PluginType.APS, true);
|
||||
|
||||
// Apply all limits
|
||||
Constraint<Double> d = new Constraint<>(Constants.REALLYHIGHIOB);
|
||||
|
@ -232,7 +232,6 @@ public class SafetyPluginTest {
|
|||
AAPSMocker.mockStrings();
|
||||
|
||||
|
||||
|
||||
when(MainApp.getConfigBuilder().getActivePump()).thenReturn(pump);
|
||||
|
||||
safetyPlugin = SafetyPlugin.getPlugin();
|
||||
|
|
|
@ -99,55 +99,21 @@ public class InsulinOrefBasePluginTest extends InsulinOrefBasePlugin {
|
|||
this.shortDiaNotificationSend = true;
|
||||
}
|
||||
|
||||
|
||||
// the following methods are implemented, but not needed...
|
||||
@Override
|
||||
String commentStandardText() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFragmentClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFriendlyName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return false;
|
||||
String commentStandardText() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPluginEnabled(int type, boolean fragmentEnabled) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferencesId() {
|
||||
return 0;
|
||||
}
|
||||
// the following methods are implemented, but not needed...
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import info.nightscout.androidaps.R;
|
|||
import info.nightscout.androidaps.db.Treatment;
|
||||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
|
||||
import info.nightscout.utils.SP;
|
||||
|
@ -37,30 +38,30 @@ public class LoopPluginTest {
|
|||
|
||||
@Test
|
||||
public void testPluginInterface() {
|
||||
Assert.assertEquals(LoopFragment.class.getName(), loopPlugin.getFragmentClass());
|
||||
Assert.assertEquals(PluginBase.LOOP, loopPlugin.getType());
|
||||
Assert.assertEquals(LoopFragment.class.getName(), loopPlugin.pluginDescription.getFragmentClass());
|
||||
Assert.assertEquals(PluginType.LOOP, loopPlugin.getType());
|
||||
Assert.assertEquals("Loop", loopPlugin.getName());
|
||||
Assert.assertEquals("LOOP", loopPlugin.getNameShort());
|
||||
Assert.assertEquals(true, loopPlugin.canBeHidden(PluginBase.LOOP));
|
||||
Assert.assertEquals(true, loopPlugin.canBeHidden(PluginType.LOOP));
|
||||
Assert.assertEquals(true, loopPlugin.hasFragment());
|
||||
Assert.assertEquals(true, loopPlugin.showInList(PluginBase.LOOP));
|
||||
Assert.assertEquals(true, loopPlugin.showInList(PluginType.LOOP));
|
||||
Assert.assertEquals(R.xml.pref_closedmode, loopPlugin.getPreferencesId());
|
||||
|
||||
// Plugin is disabled by default
|
||||
Assert.assertEquals(false, loopPlugin.isEnabled(PluginBase.LOOP));
|
||||
loopPlugin.setPluginEnabled(PluginBase.LOOP, true);
|
||||
Assert.assertEquals(true, loopPlugin.isEnabled(PluginBase.LOOP));
|
||||
Assert.assertEquals(false, loopPlugin.isEnabled(PluginType.LOOP));
|
||||
loopPlugin.setPluginEnabled(PluginType.LOOP, true);
|
||||
Assert.assertEquals(true, loopPlugin.isEnabled(PluginType.LOOP));
|
||||
|
||||
// No temp basal capable pump should disable plugin
|
||||
virtualPumpPlugin.getPumpDescription().isTempBasalCapable = false;
|
||||
Assert.assertEquals(false, loopPlugin.isEnabled(PluginBase.LOOP));
|
||||
Assert.assertEquals(false, loopPlugin.isEnabled(PluginType.LOOP));
|
||||
virtualPumpPlugin.getPumpDescription().isTempBasalCapable = true;
|
||||
|
||||
|
||||
// Fragment is hidden by default
|
||||
Assert.assertEquals(false, loopPlugin.isVisibleInTabs(PluginBase.LOOP));
|
||||
loopPlugin.setFragmentVisible(PluginBase.LOOP, true);
|
||||
Assert.assertEquals(true, loopPlugin.isVisibleInTabs(PluginBase.LOOP));
|
||||
Assert.assertEquals(false, loopPlugin.isFragmentVisible());
|
||||
loopPlugin.setFragmentVisible(PluginType.LOOP, true);
|
||||
Assert.assertEquals(true, loopPlugin.isFragmentVisible());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import org.powermock.modules.junit4.PowerMockRunner;
|
|||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.interfaces.Constraint;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.Bolus;
|
||||
import info.nightscout.utils.ToastUtils;
|
||||
|
@ -27,14 +27,14 @@ public class ComboPluginTest {
|
|||
|
||||
@Test
|
||||
public void invalidBasalRateOnComboPumpShouldLimitLoopInvokation() throws Exception {
|
||||
comboPlugin.setPluginEnabled(PluginBase.PUMP, true);
|
||||
comboPlugin.setPluginEnabled(PluginType.PUMP, true);
|
||||
comboPlugin.setValidBasalRateProfileSelectedOnPump(false);
|
||||
|
||||
Constraint<Boolean> c = new Constraint<>(true);
|
||||
c = comboPlugin.isLoopInvokationAllowed(c);
|
||||
Assert.assertEquals("Combo: No valid basal rate read from pump", c.getReasons());
|
||||
Assert.assertEquals(Boolean.FALSE, c.value());
|
||||
comboPlugin.setPluginEnabled(PluginBase.PUMP, false);
|
||||
comboPlugin.setPluginEnabled(PluginType.PUMP, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -15,7 +15,7 @@ import info.nightscout.androidaps.Constants;
|
|||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.interfaces.Constraint;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.utils.SP;
|
||||
|
@ -35,8 +35,8 @@ public class DanaRSPluginTest {
|
|||
|
||||
@Test
|
||||
public void basalRateShouldBeLimited() throws Exception {
|
||||
danaRSPlugin.setPluginEnabled(PluginBase.PUMP, true);
|
||||
danaRSPlugin.setPluginEnabled(PluginBase.PUMP, true);
|
||||
danaRSPlugin.setPluginEnabled(PluginType.PUMP, true);
|
||||
danaRSPlugin.setPluginEnabled(PluginType.PUMP, true);
|
||||
DanaRPump.getInstance().maxBasal = 0.8d;
|
||||
|
||||
Constraint<Double> c = new Constraint<>(Constants.REALLYHIGHBASALRATE);
|
||||
|
@ -48,8 +48,8 @@ public class DanaRSPluginTest {
|
|||
|
||||
@Test
|
||||
public void percentBasalRateShouldBeLimited() throws Exception {
|
||||
danaRSPlugin.setPluginEnabled(PluginBase.PUMP, true);
|
||||
danaRSPlugin.setPluginEnabled(PluginBase.PUMP, true);
|
||||
danaRSPlugin.setPluginEnabled(PluginType.PUMP, true);
|
||||
danaRSPlugin.setPluginEnabled(PluginType.PUMP, true);
|
||||
DanaRPump.getInstance().maxBasal = 0.8d;
|
||||
|
||||
Constraint<Integer> c = new Constraint<>(Constants.REALLYHIGHPERCENTBASALRATE);
|
||||
|
|
|
@ -14,7 +14,7 @@ import info.AAPSMocker;
|
|||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.interfaces.Constraint;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpInsight.connector.StatusTaskRunner;
|
||||
import info.nightscout.utils.ToastUtils;
|
||||
|
@ -31,7 +31,7 @@ public class InsightPluginTest {
|
|||
|
||||
@Test
|
||||
public void basalRateShouldBeLimited() throws Exception {
|
||||
insightPlugin.setPluginEnabled(PluginBase.PUMP, true);
|
||||
insightPlugin.setPluginEnabled(PluginType.PUMP, true);
|
||||
StatusTaskRunner.Result result = new StatusTaskRunner.Result();
|
||||
result.maximumBasalAmount = 1.1d;
|
||||
insightPlugin.setStatusResult(result);
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
package info.nightscout.androidaps.plugins.Source;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.nightscout.androidaps.Config;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
public class SourceDexcomG5PluginTest {
|
||||
|
||||
@Test
|
||||
public void getPlugin() {
|
||||
Assert.assertNotEquals(null, SourceDexcomG5Plugin.getPlugin());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void specialShowInListCondition() {
|
||||
Assert.assertEquals(!Config.G5UPLOADER, SourceDexcomG5Plugin.getPlugin().specialShowInListCondition());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void advancedFilteringSupported() {
|
||||
Assert.assertEquals(true, SourceDexcomG5Plugin.getPlugin().advancedFilteringSupported());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package info.nightscout.androidaps.plugins.Source;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.nightscout.androidaps.plugins.Source.SourceGlimpPlugin;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
public class SourceGlimpPluginTest {
|
||||
|
||||
@Test
|
||||
public void getPlugin() {
|
||||
Assert.assertNotEquals(null, SourceGlimpPlugin.getPlugin());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void advancedFilteringSupported() {
|
||||
Assert.assertEquals(false, SourceGlimpPlugin.getPlugin().advancedFilteringSupported());
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue