remove static MainApp.sConfigBuilder

This commit is contained in:
Milos Kozak 2018-09-17 19:56:56 +02:00
parent 924bc97e3b
commit a7e64c79f0
29 changed files with 79 additions and 84 deletions

View file

@ -93,7 +93,6 @@ public class MainApp extends Application {
public static Resources sResources; public static Resources sResources;
private static DatabaseHelper sDatabaseHelper = null; private static DatabaseHelper sDatabaseHelper = null;
private static ConfigBuilderPlugin sConfigBuilder = null;
private static ConstraintChecker sConstraintsChecker = null; private static ConstraintChecker sConstraintsChecker = null;
private static ArrayList<PluginBase> pluginsList = null; private static ArrayList<PluginBase> pluginsList = null;
@ -189,9 +188,9 @@ public class MainApp extends Application {
pluginsList.add(NSClientPlugin.getPlugin()); pluginsList.add(NSClientPlugin.getPlugin());
pluginsList.add(MaintenancePlugin.initPlugin(this)); pluginsList.add(MaintenancePlugin.initPlugin(this));
pluginsList.add(sConfigBuilder = ConfigBuilderPlugin.getPlugin()); pluginsList.add(ConfigBuilderPlugin.getPlugin());
MainApp.getConfigBuilder().initialize(); ConfigBuilderPlugin.getPlugin().initialize();
} }
NSUpload.uploadAppStart(); NSUpload.uploadAppStart();
@ -297,10 +296,6 @@ public class MainApp extends Application {
} }
} }
public static ConfigBuilderPlugin getConfigBuilder() {
return sConfigBuilder;
}
public static ConstraintChecker getConstraintChecker() { public static ConstraintChecker getConstraintChecker() {
return sConstraintsChecker; return sConstraintsChecker;
} }

View file

@ -43,6 +43,7 @@ import info.nightscout.androidaps.events.EventTempBasalChange;
import info.nightscout.androidaps.events.EventTempTargetChange; import info.nightscout.androidaps.events.EventTempTargetChange;
import info.nightscout.androidaps.interfaces.ProfileInterface; import info.nightscout.androidaps.interfaces.ProfileInterface;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions; import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventNewHistoryData; import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventNewHistoryData;
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload; import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
@ -1584,7 +1585,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
if (trJson.has("profileJson")) if (trJson.has("profileJson"))
profileSwitch.profileJson = trJson.getString("profileJson"); profileSwitch.profileJson = trJson.getString("profileJson");
else { else {
ProfileInterface profileInterface = MainApp.getConfigBuilder().getActiveProfileInterface(); ProfileInterface profileInterface = ConfigBuilderPlugin.getPlugin().getActiveProfileInterface();
if (profileInterface != null) { if (profileInterface != null) {
ProfileStore store = profileInterface.getProfile(); ProfileStore store = profileInterface.getProfile();
if (store != null) { if (store != null) {

View file

@ -126,7 +126,7 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
activity.runOnUiThread(new Runnable() { activity.runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
if (MainApp.getConfigBuilder().getActiveProfileInterface() != null && MainApp.getConfigBuilder().getActiveProfileInterface().getProfile() != null) { if (ConfigBuilderPlugin.getPlugin().getActiveProfileInterface() != null && ConfigBuilderPlugin.getPlugin().getActiveProfileInterface().getProfile() != null) {
profileSwitch.setVisibility(View.VISIBLE); profileSwitch.setVisibility(View.VISIBLE);
} else { } else {
profileSwitch.setVisibility(View.GONE); profileSwitch.setVisibility(View.GONE);

View file

@ -24,6 +24,7 @@ import info.nightscout.androidaps.db.CareportalEvent;
import info.nightscout.androidaps.events.EventCareportalEventChange; import info.nightscout.androidaps.events.EventCareportalEventChange;
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog; import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment; import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSettingsStatus; import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSettingsStatus;
import info.nightscout.androidaps.plugins.Overview.OverviewFragment; import info.nightscout.androidaps.plugins.Overview.OverviewFragment;
import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.FabricPrivacy;
@ -100,7 +101,7 @@ public class CareportalFragment extends SubscriberFragment implements View.OnCli
noProfileView = view.findViewById(R.id.profileview_noprofile); noProfileView = view.findViewById(R.id.profileview_noprofile);
butonsLayout = (LinearLayout) view.findViewById(R.id.careportal_buttons); butonsLayout = (LinearLayout) view.findViewById(R.id.careportal_buttons);
ProfileStore profileStore = MainApp.getConfigBuilder().getActiveProfileInterface() != null ? MainApp.getConfigBuilder().getActiveProfileInterface().getProfile() : null; ProfileStore profileStore = ConfigBuilderPlugin.getPlugin().getActiveProfileInterface() != null ? ConfigBuilderPlugin.getPlugin().getActiveProfileInterface().getProfile() : null;
if (profileStore == null) { if (profileStore == null) {
noProfileView.setVisibility(View.VISIBLE); noProfileView.setVisibility(View.VISIBLE);
butonsLayout.setVisibility(View.GONE); butonsLayout.setVisibility(View.GONE);

View file

@ -49,14 +49,15 @@ import info.nightscout.androidaps.db.ProfileSwitch;
import info.nightscout.androidaps.db.Source; import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.db.TempTarget; import info.nightscout.androidaps.db.TempTarget;
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow; import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions; import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.utils.DateUtil; import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DefaultValueHelper; import info.nightscout.utils.DefaultValueHelper;
import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.FabricPrivacy;
import info.nightscout.utils.HardLimits; import info.nightscout.utils.HardLimits;
import info.nightscout.utils.JsonHelper; import info.nightscout.utils.JsonHelper;
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
import info.nightscout.utils.NumberPicker; import info.nightscout.utils.NumberPicker;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
import info.nightscout.utils.SafeParse; import info.nightscout.utils.SafeParse;
@ -173,7 +174,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
// profile // profile
profile = ProfileFunctions.getInstance().getProfile(); profile = ProfileFunctions.getInstance().getProfile();
profileStore = MainApp.getConfigBuilder().getActiveProfileInterface().getProfile(); profileStore = ConfigBuilderPlugin.getPlugin().getActiveProfileInterface().getProfile();
if (profileStore == null) { if (profileStore == null) {
if (options.eventType == R.id.careportal_profileswitch) { if (options.eventType == R.id.careportal_profileswitch) {
log.error("Profile switch called but plugin doesn't contain valid profile"); log.error("Profile switch called but plugin doesn't contain valid profile");
@ -767,7 +768,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
profileSwitch.source = Source.USER; profileSwitch.source = Source.USER;
profileSwitch.profileName = profileName; profileSwitch.profileName = profileName;
profileSwitch.profileJson = profileStore.getSpecificProfile(profileName).getData().toString(); profileSwitch.profileJson = profileStore.getSpecificProfile(profileName).getData().toString();
profileSwitch.profilePlugin = MainApp.getConfigBuilder().getActiveProfileInterface().getClass().getName(); profileSwitch.profilePlugin = ConfigBuilderPlugin.getPlugin().getActiveProfileInterface().getClass().getName();
profileSwitch.durationInMinutes = duration; profileSwitch.durationInMinutes = duration;
profileSwitch.isCPP = percentage != 100 || timeshift != 0; profileSwitch.isCPP = percentage != 100 || timeshift != 0;
profileSwitch.timeshift = timeshift; profileSwitch.timeshift = timeshift;
@ -789,7 +790,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
profileSwitch.source = Source.USER; profileSwitch.source = Source.USER;
profileSwitch.profileName = ProfileFunctions.getInstance().getProfileName(System.currentTimeMillis(), false); profileSwitch.profileName = ProfileFunctions.getInstance().getProfileName(System.currentTimeMillis(), false);
profileSwitch.profileJson = ProfileFunctions.getInstance().getProfile().getData().toString(); profileSwitch.profileJson = ProfileFunctions.getInstance().getProfile().getData().toString();
profileSwitch.profilePlugin = MainApp.getConfigBuilder().getActiveProfileInterface().getClass().getName(); profileSwitch.profilePlugin = ConfigBuilderPlugin.getPlugin().getActiveProfileInterface().getClass().getName();
profileSwitch.durationInMinutes = duration; profileSwitch.durationInMinutes = duration;
profileSwitch.isCPP = percentage != 100 || timeshift != 0; profileSwitch.isCPP = percentage != 100 || timeshift != 0;
profileSwitch.timeshift = timeshift; profileSwitch.timeshift = timeshift;

View file

@ -49,7 +49,7 @@ public class ProfileFunctions {
public void onProfileSwitch(EventProfileSwitchChange ignored) { public void onProfileSwitch(EventProfileSwitchChange ignored) {
if (L.isEnabled(L.PROFILE)) if (L.isEnabled(L.PROFILE))
log.debug("onProfileSwitch"); log.debug("onProfileSwitch");
MainApp.getConfigBuilder().getCommandQueue().setProfile(getProfile(), new Callback() { ConfigBuilderPlugin.getPlugin().getCommandQueue().setProfile(getProfile(), new Callback() {
@Override @Override
public void run() { public void run() {
if (!result.success) { if (!result.success) {
@ -79,7 +79,7 @@ public class ProfileFunctions {
public String getProfileName(long time, boolean customized) { public String getProfileName(long time, boolean customized) {
TreatmentsInterface activeTreatments = TreatmentsPlugin.getPlugin(); TreatmentsInterface activeTreatments = TreatmentsPlugin.getPlugin();
ProfileInterface activeProfile = MainApp.getConfigBuilder().getActiveProfileInterface(); ProfileInterface activeProfile = ConfigBuilderPlugin.getPlugin().getActiveProfileInterface();
ProfileSwitch profileSwitch = activeTreatments.getProfileSwitchFromHistory(time); ProfileSwitch profileSwitch = activeTreatments.getProfileSwitchFromHistory(time);
if (profileSwitch != null) { if (profileSwitch != null) {
@ -114,7 +114,7 @@ public class ProfileFunctions {
@Nullable @Nullable
public Profile getProfile(long time) { public Profile getProfile(long time) {
TreatmentsInterface activeTreatments = TreatmentsPlugin.getPlugin(); TreatmentsInterface activeTreatments = TreatmentsPlugin.getPlugin();
ProfileInterface activeProfile = MainApp.getConfigBuilder().getActiveProfileInterface(); ProfileInterface activeProfile = ConfigBuilderPlugin.getPlugin().getActiveProfileInterface();
//log.debug("Profile for: " + new Date(time).toLocaleString() + " : " + getProfileName(time)); //log.debug("Profile for: " + new Date(time).toLocaleString() + " : " + getProfileName(time));
ProfileSwitch profileSwitch = activeTreatments.getProfileSwitchFromHistory(time); ProfileSwitch profileSwitch = activeTreatments.getProfileSwitchFromHistory(time);

View file

@ -96,7 +96,7 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
@Override @Override
public Constraint<Boolean> isAdvancedFilteringEnabled(Constraint<Boolean> value) { public Constraint<Boolean> isAdvancedFilteringEnabled(Constraint<Boolean> value) {
BgSourceInterface bgSource = MainApp.getConfigBuilder().getActiveBgSource(); BgSourceInterface bgSource = ConfigBuilderPlugin.getPlugin().getActiveBgSource();
if (bgSource != null) { if (bgSource != null) {
if (!bgSource.advancedFilteringSupported()) if (!bgSource.advancedFilteringSupported())

View file

@ -597,7 +597,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
log.debug("Ignoring event for non default instance"); log.debug("Ignoring event for non default instance");
return; return;
} }
if (MainApp.getConfigBuilder() == null) if (ConfigBuilderPlugin.getPlugin() == null)
return; // app still initializing return; // app still initializing
Profile profile = ProfileFunctions.getInstance().getProfile(); Profile profile = ProfileFunctions.getInstance().getProfile();
if (profile == null) if (profile == null)

View file

@ -26,6 +26,7 @@ import info.nightscout.androidaps.db.BgReading;
import info.nightscout.androidaps.db.TempTarget; import info.nightscout.androidaps.db.TempTarget;
import info.nightscout.androidaps.events.Event; import info.nightscout.androidaps.events.Event;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions; import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished; import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished;
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventIobCalculationProgress; import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventIobCalculationProgress;
@ -77,7 +78,7 @@ public class IobCobOref1Thread extends Thread {
try { try {
if (L.isEnabled(L.AUTOSENS)) if (L.isEnabled(L.AUTOSENS))
log.debug("AUTOSENSDATA thread started: " + from); log.debug("AUTOSENSDATA thread started: " + from);
if (MainApp.getConfigBuilder() == null) { if (ConfigBuilderPlugin.getPlugin() == null) {
if (L.isEnabled(L.AUTOSENS)) if (L.isEnabled(L.AUTOSENS))
log.debug("Aborting calculation thread (ConfigBuilder not ready): " + from); log.debug("Aborting calculation thread (ConfigBuilder not ready): " + from);
return; // app still initializing return; // app still initializing

View file

@ -24,6 +24,7 @@ import info.nightscout.androidaps.db.BgReading;
import info.nightscout.androidaps.events.Event; import info.nightscout.androidaps.events.Event;
import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions; import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished; import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished;
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventIobCalculationProgress; import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventIobCalculationProgress;
@ -76,7 +77,7 @@ public class IobCobThread extends Thread {
try { try {
if (L.isEnabled(L.AUTOSENS)) if (L.isEnabled(L.AUTOSENS))
log.debug("AUTOSENSDATA thread started: " + from); log.debug("AUTOSENSDATA thread started: " + from);
if (MainApp.getConfigBuilder() == null) { if (ConfigBuilderPlugin.getPlugin() == null) {
if (L.isEnabled(L.AUTOSENS)) if (L.isEnabled(L.AUTOSENS))
log.debug("Aborting calculation thread (ConfigBuilder not ready): " + from); log.debug("Aborting calculation thread (ConfigBuilder not ready): " + from);
return; // app still initializing return; // app still initializing

View file

@ -520,7 +520,7 @@ public class LoopPlugin extends PluginBase {
if (activeTemp != null) { if (activeTemp != null) {
if (L.isEnabled(L.APS)) if (L.isEnabled(L.APS))
log.debug("applyAPSRequest: cancelTempBasal()"); log.debug("applyAPSRequest: cancelTempBasal()");
MainApp.getConfigBuilder().getCommandQueue().cancelTempBasal(false, callback); ConfigBuilderPlugin.getPlugin().getCommandQueue().cancelTempBasal(false, callback);
} else { } else {
if (L.isEnabled(L.APS)) if (L.isEnabled(L.APS))
log.debug("applyAPSRequest: Basal set correctly"); log.debug("applyAPSRequest: Basal set correctly");
@ -543,14 +543,14 @@ public class LoopPlugin extends PluginBase {
} else { } else {
if (L.isEnabled(L.APS)) if (L.isEnabled(L.APS))
log.debug("applyAPSRequest: tempBasalPercent()"); log.debug("applyAPSRequest: tempBasalPercent()");
MainApp.getConfigBuilder().getCommandQueue().tempBasalPercent(request.percent, request.duration, false, profile, callback); ConfigBuilderPlugin.getPlugin().getCommandQueue().tempBasalPercent(request.percent, request.duration, false, profile, callback);
} }
} else { } else {
if ((request.rate == 0 && request.duration == 0) || Math.abs(request.rate - pump.getBaseBasalRate()) < pump.getPumpDescription().basalStep) { if ((request.rate == 0 && request.duration == 0) || Math.abs(request.rate - pump.getBaseBasalRate()) < pump.getPumpDescription().basalStep) {
if (activeTemp != null) { if (activeTemp != null) {
if (L.isEnabled(L.APS)) if (L.isEnabled(L.APS))
log.debug("applyAPSRequest: cancelTempBasal()"); log.debug("applyAPSRequest: cancelTempBasal()");
MainApp.getConfigBuilder().getCommandQueue().cancelTempBasal(false, callback); ConfigBuilderPlugin.getPlugin().getCommandQueue().cancelTempBasal(false, callback);
} else { } else {
if (L.isEnabled(L.APS)) if (L.isEnabled(L.APS))
log.debug("applyAPSRequest: Basal set correctly"); log.debug("applyAPSRequest: Basal set correctly");
@ -573,7 +573,7 @@ public class LoopPlugin extends PluginBase {
} else { } else {
if (L.isEnabled(L.APS)) if (L.isEnabled(L.APS))
log.debug("applyAPSRequest: setTempBasalAbsolute()"); log.debug("applyAPSRequest: setTempBasalAbsolute()");
MainApp.getConfigBuilder().getCommandQueue().tempBasalAbsolute(request.rate, request.duration, false, profile, callback); ConfigBuilderPlugin.getPlugin().getCommandQueue().tempBasalAbsolute(request.rate, request.duration, false, profile, callback);
} }
} }
} }
@ -629,7 +629,7 @@ public class LoopPlugin extends PluginBase {
detailedBolusInfo.deliverAt = request.deliverAt; detailedBolusInfo.deliverAt = request.deliverAt;
if (L.isEnabled(L.APS)) if (L.isEnabled(L.APS))
log.debug("applyAPSRequest: bolus()"); log.debug("applyAPSRequest: bolus()");
MainApp.getConfigBuilder().getCommandQueue().bolus(detailedBolusInfo, callback); ConfigBuilderPlugin.getPlugin().getCommandQueue().bolus(detailedBolusInfo, callback);
} }
public void disconnectPump(int durationInMinutes, Profile profile) { public void disconnectPump(int durationInMinutes, Profile profile) {
@ -637,7 +637,7 @@ public class LoopPlugin extends PluginBase {
TreatmentsInterface activeTreatments = TreatmentsPlugin.getPlugin(); TreatmentsInterface activeTreatments = TreatmentsPlugin.getPlugin();
LoopPlugin.getPlugin().disconnectTo(System.currentTimeMillis() + durationInMinutes * 60 * 1000L); LoopPlugin.getPlugin().disconnectTo(System.currentTimeMillis() + durationInMinutes * 60 * 1000L);
MainApp.getConfigBuilder().getCommandQueue().tempBasalPercent(0, durationInMinutes, true, profile, new Callback() { ConfigBuilderPlugin.getPlugin().getCommandQueue().tempBasalPercent(0, durationInMinutes, true, profile, new Callback() {
@Override @Override
public void run() { public void run() {
if (!result.success) { if (!result.success) {
@ -646,7 +646,7 @@ public class LoopPlugin extends PluginBase {
} }
}); });
if (pump.getPumpDescription().isExtendedBolusCapable && activeTreatments.isInHistoryExtendedBoluslInProgress()) { if (pump.getPumpDescription().isExtendedBolusCapable && activeTreatments.isInHistoryExtendedBoluslInProgress()) {
MainApp.getConfigBuilder().getCommandQueue().cancelExtended(new Callback() { ConfigBuilderPlugin.getPlugin().getCommandQueue().cancelExtended(new Callback() {
@Override @Override
public void run() { public void run() {
if (!result.success) { if (!result.success) {
@ -660,7 +660,7 @@ public class LoopPlugin extends PluginBase {
public void suspendLoop(int durationInMinutes) { public void suspendLoop(int durationInMinutes) {
LoopPlugin.getPlugin().suspendTo(System.currentTimeMillis() + durationInMinutes * 60 * 1000); LoopPlugin.getPlugin().suspendTo(System.currentTimeMillis() + durationInMinutes * 60 * 1000);
MainApp.getConfigBuilder().getCommandQueue().cancelTempBasal(true, new Callback() { ConfigBuilderPlugin.getPlugin().getCommandQueue().cancelTempBasal(true, new Callback() {
@Override @Override
public void run() { public void run() {
if (!result.success) { if (!result.success) {

View file

@ -429,7 +429,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
private void initDialog() { private void initDialog() {
Profile profile = ProfileFunctions.getInstance().getProfile(); Profile profile = ProfileFunctions.getInstance().getProfile();
ProfileStore profileStore = MainApp.getConfigBuilder().getActiveProfileInterface() != null ? MainApp.getConfigBuilder().getActiveProfileInterface().getProfile() : null; ProfileStore profileStore = ConfigBuilderPlugin.getPlugin().getActiveProfileInterface() != null ? ConfigBuilderPlugin.getPlugin().getActiveProfileInterface().getProfile() : null;
if (profile == null || profileStore == null) { if (profile == null || profileStore == null) {
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.noprofile)); ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.noprofile));
@ -473,7 +473,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
} }
private void calculateInsulin() { private void calculateInsulin() {
ProfileStore profileStore = MainApp.getConfigBuilder().getActiveProfileInterface().getProfile(); ProfileStore profileStore = ConfigBuilderPlugin.getPlugin().getActiveProfileInterface().getProfile();
if (profileSpinner == null || profileSpinner.getSelectedItem() == null || profileStore == null) if (profileSpinner == null || profileSpinner.getSelectedItem() == null || profileStore == null)
return; // not initialized yet return; // not initialized yet
String selectedAlternativeProfile = profileSpinner.getSelectedItem().toString(); String selectedAlternativeProfile = profileSpinner.getSelectedItem().toString();

View file

@ -473,7 +473,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
} else if (v == activeProfileView) { } else if (v == activeProfileView) {
menu.setHeaderTitle(MainApp.gs(R.string.profile)); menu.setHeaderTitle(MainApp.gs(R.string.profile));
menu.add(MainApp.gs(R.string.danar_viewprofile)); menu.add(MainApp.gs(R.string.danar_viewprofile));
if (MainApp.getConfigBuilder().getActiveProfileInterface() != null && MainApp.getConfigBuilder().getActiveProfileInterface().getProfile() != null) { if (ConfigBuilderPlugin.getPlugin().getActiveProfileInterface() != null && ConfigBuilderPlugin.getPlugin().getActiveProfileInterface().getProfile() != null) {
menu.add(MainApp.gs(R.string.careportal_profileswitch)); menu.add(MainApp.gs(R.string.careportal_profileswitch));
} }
} else if (v == tempTargetView) { } else if (v == tempTargetView) {
@ -497,7 +497,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
if (item.getTitle().equals(MainApp.gs(R.string.disableloop))) { if (item.getTitle().equals(MainApp.gs(R.string.disableloop))) {
loopPlugin.setPluginEnabled(PluginType.LOOP, false); loopPlugin.setPluginEnabled(PluginType.LOOP, false);
loopPlugin.setFragmentVisible(PluginType.LOOP, false); loopPlugin.setFragmentVisible(PluginType.LOOP, false);
MainApp.getConfigBuilder().storeSettings("DisablingLoop"); ConfigBuilderPlugin.getPlugin().storeSettings("DisablingLoop");
updateGUI("suspendmenu"); updateGUI("suspendmenu");
ConfigBuilderPlugin.getPlugin().getCommandQueue().cancelTempBasal(true, new Callback() { ConfigBuilderPlugin.getPlugin().getCommandQueue().cancelTempBasal(true, new Callback() {
@Override @Override
@ -512,7 +512,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
} else if (item.getTitle().equals(MainApp.gs(R.string.enableloop))) { } else if (item.getTitle().equals(MainApp.gs(R.string.enableloop))) {
loopPlugin.setPluginEnabled(PluginType.LOOP, true); loopPlugin.setPluginEnabled(PluginType.LOOP, true);
loopPlugin.setFragmentVisible(PluginType.LOOP, true); loopPlugin.setFragmentVisible(PluginType.LOOP, true);
MainApp.getConfigBuilder().storeSettings("EnablingLoop"); ConfigBuilderPlugin.getPlugin().storeSettings("EnablingLoop");
updateGUI("suspendmenu"); updateGUI("suspendmenu");
NSUpload.uploadOpenAPSOffline(0); NSUpload.uploadOpenAPSOffline(0);
return true; return true;

View file

@ -109,7 +109,7 @@ public class PersistentNotificationPlugin extends PluginBase {
String line1 = ""; String line1 = "";
if (MainApp.getConfigBuilder().getActiveProfileInterface() == null || !ProfileFunctions.getInstance().isProfileValid("Notificiation")) if (ConfigBuilderPlugin.getPlugin().getActiveProfileInterface() == null || !ProfileFunctions.getInstance().isProfileValid("Notificiation"))
return null; return null;
String units = ProfileFunctions.getInstance().getProfileUnits(); String units = ProfileFunctions.getInstance().getProfileUnits();

View file

@ -20,6 +20,7 @@ import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventInitializationChanged; import info.nightscout.androidaps.events.EventInitializationChanged;
import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaRS.DanaRSPlugin; import info.nightscout.androidaps.plugins.PumpDanaRS.DanaRSPlugin;
@ -204,7 +205,7 @@ public class DanaRUserOptionsActivity extends Activity {
} else } else
pump.lowReservoirRate = 10; pump.lowReservoirRate = 10;
MainApp.getConfigBuilder().getCommandQueue().setUserOptions(null); ConfigBuilderPlugin.getPlugin().getCommandQueue().setUserOptions(null);
finish(); finish();
} }

View file

@ -47,7 +47,7 @@ public class MsgInitConnStatusTime extends MessageBase {
(MainApp.getSpecificPlugin(DanaRKoreanPlugin.class)).setPluginEnabled(PluginType.PROFILE, true); (MainApp.getSpecificPlugin(DanaRKoreanPlugin.class)).setPluginEnabled(PluginType.PROFILE, true);
} }
MainApp.getConfigBuilder().storeSettings("ChangingDanaDriver"); ConfigBuilderPlugin.getPlugin().storeSettings("ChangingDanaDriver");
MainApp.bus().post(new EventRefreshGui()); MainApp.bus().post(new EventRefreshGui());
ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("PumpDriverChange", null); // force new connection ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("PumpDriverChange", null); // force new connection
failed = false; failed = false;

View file

@ -47,7 +47,7 @@ public class MsgInitConnStatusTime_k extends MessageBase {
(MainApp.getSpecificPlugin(DanaRPlugin.class)).setPluginEnabled(PluginType.PROFILE, true); (MainApp.getSpecificPlugin(DanaRPlugin.class)).setPluginEnabled(PluginType.PROFILE, true);
} }
MainApp.getConfigBuilder().storeSettings("ChangingKoreanDanaDriver"); ConfigBuilderPlugin.getPlugin().storeSettings("ChangingKoreanDanaDriver");
MainApp.bus().post(new EventRefreshGui()); MainApp.bus().post(new EventRefreshGui());
ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("PumpDriverChange", null); // force new connection ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("PumpDriverChange", null); // force new connection
return; return;

View file

@ -59,7 +59,7 @@ public class MsgCheckValue_v2 extends MessageBase {
(MainApp.getSpecificPlugin(DanaRKoreanPlugin.class)).setPluginEnabled(PluginType.PROFILE, true); (MainApp.getSpecificPlugin(DanaRKoreanPlugin.class)).setPluginEnabled(PluginType.PROFILE, true);
} }
MainApp.getConfigBuilder().storeSettings("ChangingDanaRv2Driver"); ConfigBuilderPlugin.getPlugin().storeSettings("ChangingDanaRv2Driver");
MainApp.bus().post(new EventRefreshGui()); MainApp.bus().post(new EventRefreshGui());
ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("PumpDriverChange", null); // force new connection ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("PumpDriverChange", null); // force new connection
return; return;
@ -82,7 +82,7 @@ public class MsgCheckValue_v2 extends MessageBase {
(MainApp.getSpecificPlugin(DanaRPlugin.class)).setPluginEnabled(PluginType.PROFILE, true); (MainApp.getSpecificPlugin(DanaRPlugin.class)).setPluginEnabled(PluginType.PROFILE, true);
} }
MainApp.getConfigBuilder().storeSettings("ChangingDanaRv2Driver"); ConfigBuilderPlugin.getPlugin().storeSettings("ChangingDanaRv2Driver");
MainApp.bus().post(new EventRefreshGui()); MainApp.bus().post(new EventRefreshGui());
ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("PumpDriverChange", null); // force new connection ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("PumpDriverChange", null); // force new connection
return; return;

View file

@ -18,6 +18,7 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventFeatureRunning; import info.nightscout.androidaps.events.EventFeatureRunning;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.PumpInsight.events.EventInsightUpdateGui; import info.nightscout.androidaps.plugins.PumpInsight.events.EventInsightUpdateGui;
import info.nightscout.androidaps.plugins.PumpInsight.history.HistoryReceiver; import info.nightscout.androidaps.plugins.PumpInsight.history.HistoryReceiver;
import info.nightscout.androidaps.plugins.PumpInsight.history.LiveHistory; import info.nightscout.androidaps.plugins.PumpInsight.history.LiveHistory;
@ -459,7 +460,7 @@ public class Connector {
public void tryToGetPumpStatusAgain() { public void tryToGetPumpStatusAgain() {
if (Helpers.ratelimit("insight-retry-status-request", 5)) { if (Helpers.ratelimit("insight-retry-status-request", 5)) {
try { try {
MainApp.getConfigBuilder().getCommandQueue().readStatus("Insight. Status missing", null); ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("Insight. Status missing", null);
} catch (NullPointerException e) { } catch (NullPointerException e) {
// //
} }

View file

@ -115,7 +115,7 @@ public class MDIPlugin extends PluginBase implements PumpInterface {
@Override @Override
public PumpEnactResult setNewBasalProfile(Profile profile) { public PumpEnactResult setNewBasalProfile(Profile profile) {
// Do nothing here. we are using MainApp.getConfigBuilder().getActiveProfile().getProfile(); // Do nothing here. we are using ConfigBuilderPlugin.getPlugin().getActiveProfile().getProfile();
PumpEnactResult result = new PumpEnactResult(); PumpEnactResult result = new PumpEnactResult();
result.success = true; result.success = true;
return result; return result;

View file

@ -197,7 +197,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
@Override @Override
public PumpEnactResult setNewBasalProfile(Profile profile) { public PumpEnactResult setNewBasalProfile(Profile profile) {
lastDataTime = System.currentTimeMillis(); lastDataTime = System.currentTimeMillis();
// Do nothing here. we are using MainApp.getConfigBuilder().getActiveProfile().getProfile(); // Do nothing here. we are using ConfigBuilderPlugin.getPlugin().getActiveProfile().getProfile();
PumpEnactResult result = new PumpEnactResult(); PumpEnactResult result = new PumpEnactResult();
result.success = true; result.success = true;
Notification notification = new Notification(Notification.PROFILE_SET_OK, MainApp.gs(R.string.profile_set_ok), Notification.INFO, 60); Notification notification = new Notification(Notification.PROFILE_SET_OK, MainApp.gs(R.string.profile_set_ok), Notification.INFO, 60);

View file

@ -15,9 +15,6 @@ import android.widget.TextView;
import com.squareup.otto.Subscribe; import com.squareup.otto.Subscribe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
@ -26,6 +23,7 @@ import info.nightscout.androidaps.R;
import info.nightscout.androidaps.db.BgReading; import info.nightscout.androidaps.db.BgReading;
import info.nightscout.androidaps.events.EventNewBG; import info.nightscout.androidaps.events.EventNewBG;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment; import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload; import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
import info.nightscout.utils.DateUtil; import info.nightscout.utils.DateUtil;
import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.FabricPrivacy;
@ -57,8 +55,8 @@ public class BGSourceFragment extends SubscriberFragment {
RecyclerViewAdapter adapter = new RecyclerViewAdapter(MainApp.getDbHelper().getAllBgreadingsDataFromTime(now - MILLS_TO_THE_PAST, false)); RecyclerViewAdapter adapter = new RecyclerViewAdapter(MainApp.getDbHelper().getAllBgreadingsDataFromTime(now - MILLS_TO_THE_PAST, false));
recyclerView.setAdapter(adapter); recyclerView.setAdapter(adapter);
if (MainApp.getConfigBuilder().getActiveProfileInterface() != null && MainApp.getConfigBuilder().getActiveProfileInterface().getProfile() != null && MainApp.getConfigBuilder().getActiveProfileInterface().getProfile().getDefaultProfile() != null) if (ConfigBuilderPlugin.getPlugin().getActiveProfileInterface() != null && ConfigBuilderPlugin.getPlugin().getActiveProfileInterface().getProfile() != null && ConfigBuilderPlugin.getPlugin().getActiveProfileInterface().getProfile().getDefaultProfile() != null)
units = MainApp.getConfigBuilder().getActiveProfileInterface().getProfile().getDefaultProfile().getUnits(); units = ConfigBuilderPlugin.getPlugin().getActiveProfileInterface().getProfile().getDefaultProfile().getUnits();
return view; return view;
} catch (Exception e) { } catch (Exception e) {

View file

@ -115,7 +115,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
if (L.isEnabled(L.DATATREATMENTS)) if (L.isEnabled(L.DATATREATMENTS))
log.debug("initializeTreatmentData"); log.debug("initializeTreatmentData");
double dia = Constants.defaultDIA; double dia = Constants.defaultDIA;
if (MainApp.getConfigBuilder() != null && ProfileFunctions.getInstance().getProfile() != null) if (ConfigBuilderPlugin.getPlugin() != null && ProfileFunctions.getInstance().getProfile() != null)
dia = ProfileFunctions.getInstance().getProfile().getDia(); dia = ProfileFunctions.getInstance().getProfile().getDia();
long fromMills = (long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + dia)); long fromMills = (long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + dia));
synchronized (treatments) { synchronized (treatments) {
@ -128,7 +128,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
if (L.isEnabled(L.DATATREATMENTS)) if (L.isEnabled(L.DATATREATMENTS))
log.debug("initializeTempBasalData"); log.debug("initializeTempBasalData");
double dia = Constants.defaultDIA; double dia = Constants.defaultDIA;
if (MainApp.getConfigBuilder() != null && ProfileFunctions.getInstance().getProfile() != null) if (ConfigBuilderPlugin.getPlugin() != null && ProfileFunctions.getInstance().getProfile() != null)
dia = ProfileFunctions.getInstance().getProfile().getDia(); dia = ProfileFunctions.getInstance().getProfile().getDia();
long fromMills = (long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + dia)); long fromMills = (long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + dia));
@ -142,7 +142,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
if (L.isEnabled(L.DATATREATMENTS)) if (L.isEnabled(L.DATATREATMENTS))
log.debug("initializeExtendedBolusData"); log.debug("initializeExtendedBolusData");
double dia = Constants.defaultDIA; double dia = Constants.defaultDIA;
if (MainApp.getConfigBuilder() != null && ProfileFunctions.getInstance().getProfile() != null) if (ConfigBuilderPlugin.getPlugin() != null && ProfileFunctions.getInstance().getProfile() != null)
dia = ProfileFunctions.getInstance().getProfile().getDia(); dia = ProfileFunctions.getInstance().getProfile().getDia();
long fromMills = (long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + dia)); long fromMills = (long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + dia));
@ -182,7 +182,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
if (profile == null) if (profile == null)
return total; return total;
InsulinInterface insulinInterface = MainApp.getConfigBuilder().getActiveInsulin(); InsulinInterface insulinInterface = ConfigBuilderPlugin.getPlugin().getActiveInsulin();
if (insulinInterface == null) if (insulinInterface == null)
return total; return total;
@ -370,7 +370,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
public IobTotal getCalculationToTimeTempBasals(long time, Profile profile, boolean truncate, long truncateTime) { public IobTotal getCalculationToTimeTempBasals(long time, Profile profile, boolean truncate, long truncateTime) {
IobTotal total = new IobTotal(time); IobTotal total = new IobTotal(time);
InsulinInterface insulinInterface = MainApp.getConfigBuilder().getActiveInsulin(); InsulinInterface insulinInterface = ConfigBuilderPlugin.getPlugin().getActiveInsulin();
if (insulinInterface == null) if (insulinInterface == null)
return total; return total;

View file

@ -230,15 +230,15 @@ public class SWDefinition {
.add(new SWButton() .add(new SWButton()
.text(R.string.insulinsourcesetup) .text(R.string.insulinsourcesetup)
.action(() -> { .action(() -> {
final PluginBase plugin = (PluginBase) MainApp.getConfigBuilder().getActiveInsulin(); final PluginBase plugin = (PluginBase) ConfigBuilderPlugin.getPlugin().getActiveInsulin();
PasswordProtection.QueryPassword(activity, R.string.settings_password, "settings_password", () -> { PasswordProtection.QueryPassword(activity, R.string.settings_password, "settings_password", () -> {
Intent i = new Intent(activity, PreferencesActivity.class); Intent i = new Intent(activity, PreferencesActivity.class);
i.putExtra("id", plugin.getPreferencesId()); i.putExtra("id", plugin.getPreferencesId());
activity.startActivity(i); activity.startActivity(i);
}, null); }, null);
}) })
.visibility(() -> MainApp.getConfigBuilder().getActiveInsulin()!= null && ((PluginBase) MainApp.getConfigBuilder().getActiveInsulin()).getPreferencesId() > 0)) .visibility(() -> ConfigBuilderPlugin.getPlugin().getActiveInsulin()!= null && ((PluginBase) ConfigBuilderPlugin.getPlugin().getActiveInsulin()).getPreferencesId() > 0))
.validator(() -> MainApp.getConfigBuilder().getActiveInsulin() != null) .validator(() -> ConfigBuilderPlugin.getPlugin().getActiveInsulin() != null)
) )
.add(new SWScreen(R.string.configbuilder_bgsource) .add(new SWScreen(R.string.configbuilder_bgsource)
.skippable(false) .skippable(false)
@ -249,15 +249,15 @@ public class SWDefinition {
.add(new SWButton() .add(new SWButton()
.text(R.string.bgsourcesetup) .text(R.string.bgsourcesetup)
.action(() -> { .action(() -> {
final PluginBase plugin = (PluginBase) MainApp.getConfigBuilder().getActiveBgSource(); final PluginBase plugin = (PluginBase) ConfigBuilderPlugin.getPlugin().getActiveBgSource();
PasswordProtection.QueryPassword(activity, R.string.settings_password, "settings_password", () -> { PasswordProtection.QueryPassword(activity, R.string.settings_password, "settings_password", () -> {
Intent i = new Intent(activity, PreferencesActivity.class); Intent i = new Intent(activity, PreferencesActivity.class);
i.putExtra("id", plugin.getPreferencesId()); i.putExtra("id", plugin.getPreferencesId());
activity.startActivity(i); activity.startActivity(i);
}, null); }, null);
}) })
.visibility(() -> MainApp.getConfigBuilder().getActiveBgSource()!= null && ((PluginBase) MainApp.getConfigBuilder().getActiveBgSource()).getPreferencesId() > 0)) .visibility(() -> ConfigBuilderPlugin.getPlugin().getActiveBgSource()!= null && ((PluginBase) ConfigBuilderPlugin.getPlugin().getActiveBgSource()).getPreferencesId() > 0))
.validator(() -> MainApp.getConfigBuilder().getActiveBgSource() != null) .validator(() -> ConfigBuilderPlugin.getPlugin().getActiveBgSource() != null)
) )
.add(new SWScreen(R.string.configbuilder_profile) .add(new SWScreen(R.string.configbuilder_profile)
.skippable(false) .skippable(false)
@ -267,7 +267,7 @@ public class SWDefinition {
.add(new SWPlugin() .add(new SWPlugin()
.option(PluginType.PROFILE, R.string.configbuilder_profile_description) .option(PluginType.PROFILE, R.string.configbuilder_profile_description)
.label(R.string.configbuilder_profile)) .label(R.string.configbuilder_profile))
.validator(() -> MainApp.getConfigBuilder().getActiveProfileInterface() != null) .validator(() -> ConfigBuilderPlugin.getPlugin().getActiveProfileInterface() != null)
) )
.add(new SWScreen(R.string.nsprofile) .add(new SWScreen(R.string.nsprofile)
.skippable(false) .skippable(false)
@ -353,15 +353,15 @@ public class SWDefinition {
.add(new SWButton() .add(new SWButton()
.text(R.string.apssetup) .text(R.string.apssetup)
.action(() -> { .action(() -> {
final PluginBase plugin = (PluginBase) MainApp.getConfigBuilder().getActiveAPS(); final PluginBase plugin = (PluginBase) ConfigBuilderPlugin.getPlugin().getActiveAPS();
PasswordProtection.QueryPassword(activity, R.string.settings_password, "settings_password", () -> { PasswordProtection.QueryPassword(activity, R.string.settings_password, "settings_password", () -> {
Intent i = new Intent(activity, PreferencesActivity.class); Intent i = new Intent(activity, PreferencesActivity.class);
i.putExtra("id", plugin.getPreferencesId()); i.putExtra("id", plugin.getPreferencesId());
activity.startActivity(i); activity.startActivity(i);
}, null); }, null);
}) })
.visibility(() -> MainApp.getConfigBuilder().getActiveAPS() != null && ((PluginBase) MainApp.getConfigBuilder().getActiveAPS()).getPreferencesId() > 0)) .visibility(() -> ConfigBuilderPlugin.getPlugin().getActiveAPS() != null && ((PluginBase) ConfigBuilderPlugin.getPlugin().getActiveAPS()).getPreferencesId() > 0))
.validator(() -> MainApp.getConfigBuilder().getActiveAPS() != null) .validator(() -> ConfigBuilderPlugin.getPlugin().getActiveAPS() != null)
.visibility(() -> Config.APS) .visibility(() -> Config.APS)
) )
.add(new SWScreen(R.string.apsmode_title) .add(new SWScreen(R.string.apsmode_title)
@ -405,15 +405,15 @@ public class SWDefinition {
.add(new SWButton() .add(new SWButton()
.text(R.string.sensitivitysetup) .text(R.string.sensitivitysetup)
.action(() -> { .action(() -> {
final PluginBase plugin = (PluginBase) MainApp.getConfigBuilder().getActiveSensitivity(); final PluginBase plugin = (PluginBase) ConfigBuilderPlugin.getPlugin().getActiveSensitivity();
PasswordProtection.QueryPassword(activity, R.string.settings_password, "settings_password", () -> { PasswordProtection.QueryPassword(activity, R.string.settings_password, "settings_password", () -> {
Intent i = new Intent(activity, PreferencesActivity.class); Intent i = new Intent(activity, PreferencesActivity.class);
i.putExtra("id", plugin.getPreferencesId()); i.putExtra("id", plugin.getPreferencesId());
activity.startActivity(i); activity.startActivity(i);
}, null); }, null);
}) })
.visibility(() -> MainApp.getConfigBuilder().getActiveSensitivity() != null && ((PluginBase) MainApp.getConfigBuilder().getActiveSensitivity()).getPreferencesId() > 0)) .visibility(() -> ConfigBuilderPlugin.getPlugin().getActiveSensitivity() != null && ((PluginBase) ConfigBuilderPlugin.getPlugin().getActiveSensitivity()).getPreferencesId() > 0))
.validator(() -> MainApp.getConfigBuilder().getActiveSensitivity() != null) .validator(() -> ConfigBuilderPlugin.getPlugin().getActiveSensitivity() != null)
) )
.add(new SWScreen(R.string.objectives) .add(new SWScreen(R.string.objectives)
.skippable(false) .skippable(false)
@ -563,15 +563,15 @@ public class SWDefinition {
.add(new SWButton() .add(new SWButton()
.text(R.string.bgsourcesetup) .text(R.string.bgsourcesetup)
.action(() -> { .action(() -> {
final PluginBase plugin = (PluginBase) MainApp.getConfigBuilder().getActiveBgSource(); final PluginBase plugin = (PluginBase) ConfigBuilderPlugin.getPlugin().getActiveBgSource();
PasswordProtection.QueryPassword(activity, R.string.settings_password, "settings_password", () -> { PasswordProtection.QueryPassword(activity, R.string.settings_password, "settings_password", () -> {
Intent i = new Intent(activity, PreferencesActivity.class); Intent i = new Intent(activity, PreferencesActivity.class);
i.putExtra("id", plugin.getPreferencesId()); i.putExtra("id", plugin.getPreferencesId());
activity.startActivity(i); activity.startActivity(i);
}, null); }, null);
}) })
.visibility(() -> MainApp.getConfigBuilder().getActiveBgSource()!= null && ((PluginBase) MainApp.getConfigBuilder().getActiveBgSource()).getPreferencesId() > 0)) .visibility(() -> ConfigBuilderPlugin.getPlugin().getActiveBgSource()!= null && ((PluginBase) ConfigBuilderPlugin.getPlugin().getActiveBgSource()).getPreferencesId() > 0))
.validator(() -> MainApp.getConfigBuilder().getActiveBgSource() != null) .validator(() -> ConfigBuilderPlugin.getPlugin().getActiveBgSource() != null)
) )
.add(new SWScreen(R.string.patientage) .add(new SWScreen(R.string.patientage)
.skippable(false) .skippable(false)
@ -598,15 +598,15 @@ public class SWDefinition {
.add(new SWButton() .add(new SWButton()
.text(R.string.insulinsourcesetup) .text(R.string.insulinsourcesetup)
.action(() -> { .action(() -> {
final PluginBase plugin = (PluginBase) MainApp.getConfigBuilder().getActiveInsulin(); final PluginBase plugin = (PluginBase) ConfigBuilderPlugin.getPlugin().getActiveInsulin();
PasswordProtection.QueryPassword(activity, R.string.settings_password, "settings_password", () -> { PasswordProtection.QueryPassword(activity, R.string.settings_password, "settings_password", () -> {
Intent i = new Intent(activity, PreferencesActivity.class); Intent i = new Intent(activity, PreferencesActivity.class);
i.putExtra("id", plugin.getPreferencesId()); i.putExtra("id", plugin.getPreferencesId());
activity.startActivity(i); activity.startActivity(i);
}, null); }, null);
}) })
.visibility(() -> MainApp.getConfigBuilder().getActiveInsulin()!= null && ((PluginBase) MainApp.getConfigBuilder().getActiveInsulin()).getPreferencesId() > 0)) .visibility(() -> ConfigBuilderPlugin.getPlugin().getActiveInsulin()!= null && ((PluginBase) ConfigBuilderPlugin.getPlugin().getActiveInsulin()).getPreferencesId() > 0))
.validator(() -> MainApp.getConfigBuilder().getActiveInsulin() != null) .validator(() -> ConfigBuilderPlugin.getPlugin().getActiveInsulin() != null)
) )
.add(new SWScreen(R.string.configbuilder_sensitivity) .add(new SWScreen(R.string.configbuilder_sensitivity)
.skippable(false) .skippable(false)
@ -622,15 +622,15 @@ public class SWDefinition {
.add(new SWButton() .add(new SWButton()
.text(R.string.sensitivitysetup) .text(R.string.sensitivitysetup)
.action(() -> { .action(() -> {
final PluginBase plugin = (PluginBase) MainApp.getConfigBuilder().getActiveSensitivity(); final PluginBase plugin = (PluginBase) ConfigBuilderPlugin.getPlugin().getActiveSensitivity();
PasswordProtection.QueryPassword(activity, R.string.settings_password, "settings_password", () -> { PasswordProtection.QueryPassword(activity, R.string.settings_password, "settings_password", () -> {
Intent i = new Intent(activity, PreferencesActivity.class); Intent i = new Intent(activity, PreferencesActivity.class);
i.putExtra("id", plugin.getPreferencesId()); i.putExtra("id", plugin.getPreferencesId());
activity.startActivity(i); activity.startActivity(i);
}, null); }, null);
}) })
.visibility(() -> MainApp.getConfigBuilder().getActiveSensitivity() != null && ((PluginBase) MainApp.getConfigBuilder().getActiveSensitivity()).getPreferencesId() > 0)) .visibility(() -> ConfigBuilderPlugin.getPlugin().getActiveSensitivity() != null && ((PluginBase) ConfigBuilderPlugin.getPlugin().getActiveSensitivity()).getPreferencesId() > 0))
.validator(() -> MainApp.getConfigBuilder().getActiveSensitivity() != null) .validator(() -> ConfigBuilderPlugin.getPlugin().getActiveSensitivity() != null)
) )
; ;
} }

View file

@ -113,7 +113,6 @@ public class AAPSMocker {
public static void mockConfigBuilder() { public static void mockConfigBuilder() {
PowerMockito.mockStatic(ConfigBuilderPlugin.class); PowerMockito.mockStatic(ConfigBuilderPlugin.class);
ConfigBuilderPlugin configBuilderPlugin = mock(ConfigBuilderPlugin.class); ConfigBuilderPlugin configBuilderPlugin = mock(ConfigBuilderPlugin.class);
when(MainApp.getConfigBuilder()).thenReturn(configBuilderPlugin);
when(ConfigBuilderPlugin.getPlugin()).thenReturn(configBuilderPlugin); when(ConfigBuilderPlugin.getPlugin()).thenReturn(configBuilderPlugin);
} }

View file

@ -10,6 +10,7 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Maintenance.LoggerUtils; import info.nightscout.androidaps.plugins.Maintenance.LoggerUtils;
import info.nightscout.androidaps.plugins.Overview.OverviewPlugin; import info.nightscout.androidaps.plugins.Overview.OverviewPlugin;
@ -54,11 +55,6 @@ public class MainAppTest {
Assert.assertNull(mainApp.getDbHelper()); Assert.assertNull(mainApp.getDbHelper());
} }
@Test
public void getConfigBuilderTest() {
Assert.assertNotNull(mainApp.getConfigBuilder());
}
@Test @Test
public void getConstraintCheckerTest() { public void getConstraintCheckerTest() {
Assert.assertNotNull(mainApp.getConstraintChecker()); Assert.assertNotNull(mainApp.getConstraintChecker());

View file

@ -113,7 +113,7 @@ public class ConstraintsCheckerTest {
@Test @Test
public void isAdvancedFilteringEnabledTest() throws Exception { public void isAdvancedFilteringEnabledTest() throws Exception {
when(MainApp.getConfigBuilder().getActiveBgSource()).thenReturn(SourceGlimpPlugin.getPlugin()); when(ConfigBuilderPlugin.getPlugin().getActiveBgSource()).thenReturn(SourceGlimpPlugin.getPlugin());
Constraint<Boolean> c = constraintChecker.isAdvancedFilteringEnabled(); Constraint<Boolean> c = constraintChecker.isAdvancedFilteringEnabled();
Assert.assertEquals(true, c.getReasonList().size() == 1); // Safety Assert.assertEquals(true, c.getReasonList().size() == 1); // Safety

View file

@ -72,7 +72,7 @@ public class NewNSTreatmentDialogTest {
AAPSMocker.mockDatabaseHelper(); AAPSMocker.mockDatabaseHelper();
NSProfilePlugin profilePlugin = NSProfilePlugin.getPlugin(); NSProfilePlugin profilePlugin = NSProfilePlugin.getPlugin();
when(MainApp.getConfigBuilder().getActiveProfileInterface()) when(ConfigBuilderPlugin.getPlugin().getActiveProfileInterface())
.thenReturn(profilePlugin); .thenReturn(profilePlugin);
dialog = new NewNSTreatmentDialog(); dialog = new NewNSTreatmentDialog();

View file

@ -91,7 +91,7 @@ public class SafetyPluginTest {
@Test @Test
public void bgsourceShouldPreventSMBAlways() throws Exception { public void bgsourceShouldPreventSMBAlways() throws Exception {
when(MainApp.getConfigBuilder().getActiveBgSource()).thenReturn(SourceGlimpPlugin.getPlugin()); when(ConfigBuilderPlugin.getPlugin().getActiveBgSource()).thenReturn(SourceGlimpPlugin.getPlugin());
Constraint<Boolean> c = new Constraint<>(true); Constraint<Boolean> c = new Constraint<>(true);
c = safetyPlugin.isAdvancedFilteringEnabled(c); c = safetyPlugin.isAdvancedFilteringEnabled(c);