move profile function from ConfigBuilder to extra class
This commit is contained in:
parent
188a9b6313
commit
4ec0ebfa74
60 changed files with 313 additions and 205 deletions
|
@ -49,6 +49,7 @@ import info.nightscout.androidaps.events.EventPreferenceChange;
|
|||
import info.nightscout.androidaps.events.EventRefreshGui;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.Food.FoodPlugin;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSettingsStatus;
|
||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||
|
@ -291,7 +292,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
private void checkUpgradeToProfileTarget() { // TODO: can be removed in the future
|
||||
boolean oldKeyExists = SP.contains("openapsma_min_bg");
|
||||
if (oldKeyExists) {
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
String oldRange = SP.getDouble("openapsma_min_bg", 0d) + " - " + SP.getDouble("openapsma_max_bg", 0d);
|
||||
String newRange = "";
|
||||
if (profile != null) {
|
||||
|
|
|
@ -107,7 +107,6 @@ public class MainApp extends Application {
|
|||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
if (L.isEnabled(L.CORE))
|
||||
log.debug("onCreate");
|
||||
sInstance = this;
|
||||
sResources = getResources();
|
||||
|
|
|
@ -35,6 +35,7 @@ import info.nightscout.androidaps.data.Profile;
|
|||
import info.nightscout.androidaps.events.EventCustomCalculationFinished;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventIobCalculationProgress;
|
||||
|
@ -229,7 +230,7 @@ public class HistoryBrowseActivity extends AppCompatActivity {
|
|||
return;
|
||||
|
||||
final PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
final Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
|
||||
if (profile == null) {
|
||||
noProfile.setVisibility(View.VISIBLE);
|
||||
|
|
|
@ -40,6 +40,7 @@ import info.nightscout.androidaps.db.TDD;
|
|||
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRSyncStatus;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
|
||||
|
@ -121,7 +122,7 @@ public class TDDStatsActivity extends Activity {
|
|||
|
||||
TBB = SP.getString("TBB", "10.00");
|
||||
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
if (profile != null) {
|
||||
double cppTBB = profile.baseBasalSum();
|
||||
TBB = decimalFormat.format(cppTBB);
|
||||
|
|
|
@ -15,6 +15,7 @@ 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.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSgv;
|
||||
import info.nightscout.androidaps.plugins.Overview.OverviewPlugin;
|
||||
import info.nightscout.androidaps.plugins.Overview.graphExtensions.DataPointWithLabelInterface;
|
||||
|
@ -168,7 +169,7 @@ public class BgReading implements DataPointWithLabelInterface {
|
|||
|
||||
@Override
|
||||
public double getY() {
|
||||
String units = MainApp.getConfigBuilder().getProfileUnits();
|
||||
String units = ProfileFunctions.getInstance().getProfileUnits();
|
||||
return valueToUnits(units);
|
||||
}
|
||||
|
||||
|
@ -202,7 +203,7 @@ public class BgReading implements DataPointWithLabelInterface {
|
|||
|
||||
@Override
|
||||
public int getColor() {
|
||||
String units = MainApp.getConfigBuilder().getProfileUnits();
|
||||
String units = ProfileFunctions.getInstance().getProfileUnits();
|
||||
Double lowLine = SP.getDouble("low_mark", 0d);
|
||||
Double highLine = SP.getDouble("high_mark", 0d);
|
||||
if (lowLine < 1) {
|
||||
|
|
|
@ -25,6 +25,7 @@ import info.nightscout.androidaps.MainApp;
|
|||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.interfaces.Interval;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSMbg;
|
||||
import info.nightscout.androidaps.plugins.Overview.OverviewFragment;
|
||||
import info.nightscout.androidaps.plugins.Overview.graphExtensions.DataPointWithLabelInterface;
|
||||
|
@ -153,7 +154,7 @@ public class CareportalEvent implements DataPointWithLabelInterface, Interval {
|
|||
|
||||
@Override
|
||||
public double getY() {
|
||||
String units = MainApp.getConfigBuilder().getProfileUnits();
|
||||
String units = ProfileFunctions.getInstance().getProfileUnits();
|
||||
if (eventType.equals(MBG)) {
|
||||
double mbg = 0d;
|
||||
try {
|
||||
|
|
|
@ -42,6 +42,7 @@ import info.nightscout.androidaps.events.EventReloadTreatmentData;
|
|||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||
import info.nightscout.androidaps.events.EventTempTargetChange;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventNewHistoryData;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.activities.DanaRNSHistorySync;
|
||||
|
@ -691,7 +692,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
|||
|
||||
public void createTemptargetFromJsonIfNotExists(JSONObject trJson) {
|
||||
try {
|
||||
String units = JsonHelper.safeGetString(trJson, "units", MainApp.getConfigBuilder().getProfileUnits());
|
||||
String units = JsonHelper.safeGetString(trJson, "units", ProfileFunctions.getInstance().getProfileUnits());
|
||||
TempTarget tempTarget = new TempTarget()
|
||||
.date(trJson.getLong("mills"))
|
||||
.duration(trJson.getInt("duration"))
|
||||
|
|
|
@ -16,6 +16,7 @@ import info.nightscout.androidaps.data.Profile;
|
|||
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
||||
import info.nightscout.androidaps.interfaces.Interval;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
|
@ -93,7 +94,7 @@ public class TemporaryBasal implements Interval {
|
|||
}
|
||||
|
||||
public TemporaryBasal(ExtendedBolus extendedBolus) {
|
||||
double basal = MainApp.getConfigBuilder().getProfile(extendedBolus.date).getBasal(extendedBolus.date);
|
||||
double basal = ProfileFunctions.getInstance().getProfile(extendedBolus.date).getBasal(extendedBolus.date);
|
||||
this.date = extendedBolus.date;
|
||||
this.isValid = extendedBolus.isValid;
|
||||
this.source = extendedBolus.source;
|
||||
|
@ -318,7 +319,7 @@ public class TemporaryBasal implements Interval {
|
|||
public String toStringFull() {
|
||||
if(isFakeExtended){
|
||||
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
Double currentBasalRate = profile.getBasal();
|
||||
double rate = (currentBasalRate == null)?0d:(currentBasalRate+netExtendedRate);
|
||||
return getCalcuatedPercentageIfNeeded() + DecimalFormatter.to2Decimal(rate) + "U/h ("+DecimalFormatter.to2Decimal(netExtendedRate)+"E) @" +
|
||||
|
@ -340,7 +341,7 @@ public class TemporaryBasal implements Interval {
|
|||
|
||||
double rate = 0d;
|
||||
if (isFakeExtended) {
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
Double currentBasalRate = profile.getBasal();
|
||||
rate = (currentBasalRate == null)?0d:(currentBasalRate+netExtendedRate);
|
||||
} else if (isAbsolute){
|
||||
|
@ -348,7 +349,7 @@ public class TemporaryBasal implements Interval {
|
|||
}
|
||||
|
||||
if(SP.getBoolean(R.string.key_danar_visualizeextendedaspercentage, false) && SP.getBoolean(R.string.key_danar_useextended, false)){
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
if(profile != null) {
|
||||
double basal = profile.getBasal();
|
||||
if(basal != 0){
|
||||
|
@ -367,7 +368,7 @@ public class TemporaryBasal implements Interval {
|
|||
|
||||
double rate = 0d;
|
||||
if (isFakeExtended) {
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
Double currentBasalRate = profile.getBasal();
|
||||
rate = (currentBasalRate == null)?0d:(currentBasalRate+netExtendedRate);
|
||||
} else if (isAbsolute){
|
||||
|
@ -375,7 +376,7 @@ public class TemporaryBasal implements Interval {
|
|||
}
|
||||
|
||||
if(SP.getBoolean(R.string.key_danar_visualizeextendedaspercentage, false) && SP.getBoolean(R.string.key_danar_useextended, false)){
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
if(profile != null) {
|
||||
double basal = profile.getBasal();
|
||||
if(basal != 0){
|
||||
|
@ -392,7 +393,7 @@ public class TemporaryBasal implements Interval {
|
|||
|
||||
double rate = 0d;
|
||||
if (isFakeExtended) {
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
Double currentBasalRate = profile.getBasal();
|
||||
rate = (currentBasalRate == null)?0d:(currentBasalRate+netExtendedRate);
|
||||
} else if (isAbsolute){
|
||||
|
|
|
@ -33,6 +33,7 @@ import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialo
|
|||
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
|
||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||
import info.nightscout.utils.FabricPrivacy;
|
||||
import info.nightscout.utils.SingleClickButton;
|
||||
|
@ -131,7 +132,7 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
|
|||
profileSwitch.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (MainApp.getConfigBuilder().getProfile() == null) {
|
||||
if (ProfileFunctions.getInstance().getProfile() == null) {
|
||||
tempTarget.setVisibility(View.GONE);
|
||||
extendedBolus.setVisibility(View.GONE);
|
||||
extendedBolusCancel.setVisibility(View.GONE);
|
||||
|
|
|
@ -25,6 +25,7 @@ import info.nightscout.androidaps.data.Profile;
|
|||
import info.nightscout.androidaps.interfaces.Constraint;
|
||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity;
|
||||
import info.nightscout.androidaps.queue.Callback;
|
||||
import info.nightscout.utils.FabricPrivacy;
|
||||
|
@ -70,7 +71,7 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi
|
|||
double tempPercentStep = pumpDescription.tempPercentStep;
|
||||
basalPercent.setParams(100d, 0d, maxTempPercent, tempPercentStep, new DecimalFormat("0"), true);
|
||||
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
Double currentBasal = profile != null ? profile.getBasal() : 0d;
|
||||
basalAbsolute = (NumberPicker) view.findViewById(R.id.overview_newtempbasal_basalabsoluteinput);
|
||||
basalAbsolute.setParams(currentBasal, 0d, pumpDescription.maxTempAbsolute, pumpDescription.tempAbsoluteStep, new DecimalFormat("0.00"), true);
|
||||
|
@ -118,7 +119,7 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi
|
|||
final boolean setAsPercent = percentRadio.isChecked();
|
||||
int durationInMinutes = SafeParse.stringToInt(duration.getText());
|
||||
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
if (profile == null)
|
||||
return;
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ import info.nightscout.androidaps.db.ProfileSwitch;
|
|||
import info.nightscout.androidaps.db.Source;
|
||||
import info.nightscout.androidaps.db.TempTarget;
|
||||
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.DefaultValueHelper;
|
||||
|
@ -171,7 +172,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
view.findViewById(R.id.cancel).setOnClickListener(this);
|
||||
|
||||
// profile
|
||||
profile = MainApp.getConfigBuilder().getProfile();
|
||||
profile = ProfileFunctions.getInstance().getProfile();
|
||||
profileStore = MainApp.getConfigBuilder().getActiveProfileInterface().getProfile();
|
||||
if (profileStore == null) {
|
||||
if (options.eventType == R.id.careportal_profileswitch) {
|
||||
|
@ -186,7 +187,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
profileSpinner.setAdapter(adapter);
|
||||
// set selected to actual profile
|
||||
for (int p = 0; p < profileList.size(); p++) {
|
||||
if (profileList.get(p).equals(MainApp.getConfigBuilder().getProfileName(false)))
|
||||
if (profileList.get(p).equals(ProfileFunctions.getInstance().getProfileName(false)))
|
||||
profileSpinner.setSelection(p);
|
||||
}
|
||||
}
|
||||
|
@ -214,7 +215,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
}
|
||||
boolean erase = false;
|
||||
|
||||
String units = MainApp.getConfigBuilder().getProfileUnits();
|
||||
String units = ProfileFunctions.getInstance().getProfileUnits();
|
||||
DefaultValueHelper helper = new DefaultValueHelper();
|
||||
if (MainApp.gs(R.string.eatingsoon).equals(reasonList.get(position))) {
|
||||
defaultDuration = helper.determineEatingSoonTTDuration();
|
||||
|
@ -786,8 +787,8 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
profileSwitch = new ProfileSwitch();
|
||||
profileSwitch.date = System.currentTimeMillis();
|
||||
profileSwitch.source = Source.USER;
|
||||
profileSwitch.profileName = MainApp.getConfigBuilder().getProfileName(System.currentTimeMillis(), false);
|
||||
profileSwitch.profileJson = MainApp.getConfigBuilder().getProfile().getData().toString();
|
||||
profileSwitch.profileName = ProfileFunctions.getInstance().getProfileName(System.currentTimeMillis(), false);
|
||||
profileSwitch.profileJson = ProfileFunctions.getInstance().getProfile().getData().toString();
|
||||
profileSwitch.profilePlugin = MainApp.getConfigBuilder().getActiveProfileInterface().getClass().getName();
|
||||
profileSwitch.durationInMinutes = duration;
|
||||
profileSwitch.isCPP = percentage != 100 || timeshift != 0;
|
||||
|
|
|
@ -530,97 +530,7 @@ public class ConfigBuilderPlugin extends PluginBase {
|
|||
getCommandQueue().bolus(detailedBolusInfo, callback);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onProfileSwitch(EventProfileSwitchChange ignored) {
|
||||
getCommandQueue().setProfile(getProfile(), new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!result.success) {
|
||||
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
|
||||
i.putExtra("soundid", R.raw.boluserror);
|
||||
i.putExtra("status", result.comment);
|
||||
i.putExtra("title", MainApp.gs(R.string.failedupdatebasalprofile));
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
MainApp.instance().startActivity(i);
|
||||
}
|
||||
MainApp.bus().post(new EventNewBasalProfile());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public String getProfileName() {
|
||||
return getProfileName(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public String getProfileName(boolean customized) {
|
||||
return getProfileName(System.currentTimeMillis(), customized);
|
||||
}
|
||||
|
||||
public String getProfileName(long time) {
|
||||
return getProfileName(time, true);
|
||||
}
|
||||
|
||||
public String getProfileName(long time, boolean customized) {
|
||||
ProfileSwitch profileSwitch = activeTreatments.getProfileSwitchFromHistory(time);
|
||||
if (profileSwitch != null) {
|
||||
if (profileSwitch.profileJson != null) {
|
||||
return customized ? profileSwitch.getCustomizedName() : profileSwitch.profileName;
|
||||
} else {
|
||||
ProfileStore profileStore = activeProfile.getProfile();
|
||||
if (profileStore != null) {
|
||||
Profile profile = profileStore.getSpecificProfile(profileSwitch.profileName);
|
||||
if (profile != null)
|
||||
return profileSwitch.profileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
return MainApp.gs(R.string.noprofileselected);
|
||||
}
|
||||
|
||||
public boolean isProfileValid(String from) {
|
||||
return getProfile() != null && getProfile().isValid(from);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Profile getProfile() {
|
||||
return getProfile(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public String getProfileUnits() {
|
||||
Profile profile = getProfile();
|
||||
return profile != null ? profile.getUnits() : Constants.MGDL;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Profile getProfile(long time) {
|
||||
if (activeTreatments == null) {
|
||||
log.debug("getProfile activeTreatments == null: returning null");
|
||||
return null; //app not initialized
|
||||
}
|
||||
//log.debug("Profile for: " + new Date(time).toLocaleString() + " : " + getProfileName(time));
|
||||
ProfileSwitch profileSwitch = activeTreatments.getProfileSwitchFromHistory(time);
|
||||
if (profileSwitch != null) {
|
||||
if (profileSwitch.profileJson != null) {
|
||||
return profileSwitch.getProfileObject();
|
||||
} else if (activeProfile.getProfile() != null) {
|
||||
Profile profile = activeProfile.getProfile().getSpecificProfile(profileSwitch.profileName);
|
||||
if (profile != null)
|
||||
return profile;
|
||||
}
|
||||
}
|
||||
if (activeTreatments.getProfileSwitchesFromHistory().size() > 0) {
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("CatchedError")
|
||||
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
|
||||
.putCustomAttribute("version", BuildConfig.VERSION)
|
||||
.putCustomAttribute("time", time)
|
||||
.putCustomAttribute("getProfileSwitchesFromHistory", activeTreatments.getProfileSwitchesFromHistory().toString())
|
||||
);
|
||||
}
|
||||
log.debug("getProfile at the end: returning null");
|
||||
return null;
|
||||
}
|
||||
|
||||
public void disconnectPump(int durationInMinutes, Profile profile) {
|
||||
public void disconnectPump(int durationInMinutes, Profile profile) {
|
||||
LoopPlugin.getPlugin().disconnectTo(System.currentTimeMillis() + durationInMinutes * 60 * 1000L);
|
||||
getCommandQueue().tempBasalPercent(0, durationInMinutes, true, profile, new Callback() {
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,142 @@
|
|||
package info.nightscout.androidaps.plugins.ConfigBuilder;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.crashlytics.android.answers.CustomEvent;
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.BuildConfig;
|
||||
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.data.ProfileStore;
|
||||
import info.nightscout.androidaps.db.ProfileSwitch;
|
||||
import info.nightscout.androidaps.events.EventNewBasalProfile;
|
||||
import info.nightscout.androidaps.events.EventProfileSwitchChange;
|
||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity;
|
||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||
import info.nightscout.androidaps.queue.Callback;
|
||||
import info.nightscout.utils.FabricPrivacy;
|
||||
|
||||
public class ProfileFunctions {
|
||||
private static Logger log = LoggerFactory.getLogger(L.PROFILE);
|
||||
|
||||
private static ProfileFunctions profileFunctions = null;
|
||||
|
||||
public static ProfileFunctions getInstance() {
|
||||
if (profileFunctions == null)
|
||||
profileFunctions = new ProfileFunctions();
|
||||
return profileFunctions;
|
||||
}
|
||||
|
||||
static {
|
||||
ProfileFunctions.getInstance(); // register to bus at start
|
||||
}
|
||||
|
||||
ProfileFunctions() {
|
||||
MainApp.bus().register(this);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onProfileSwitch(EventProfileSwitchChange ignored) {
|
||||
if (L.isEnabled(L.PROFILE))
|
||||
log.debug("onProfileSwitch");
|
||||
MainApp.getConfigBuilder().getCommandQueue().setProfile(getProfile(), new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!result.success) {
|
||||
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
|
||||
i.putExtra("soundid", R.raw.boluserror);
|
||||
i.putExtra("status", result.comment);
|
||||
i.putExtra("title", MainApp.gs(R.string.failedupdatebasalprofile));
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
MainApp.instance().startActivity(i);
|
||||
}
|
||||
MainApp.bus().post(new EventNewBasalProfile());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public String getProfileName() {
|
||||
return getProfileName(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public String getProfileName(boolean customized) {
|
||||
return getProfileName(System.currentTimeMillis(), customized);
|
||||
}
|
||||
|
||||
public String getProfileName(long time) {
|
||||
return getProfileName(time, true);
|
||||
}
|
||||
|
||||
public String getProfileName(long time, boolean customized) {
|
||||
TreatmentsInterface activeTreatments = TreatmentsPlugin.getPlugin();
|
||||
ProfileInterface activeProfile = MainApp.getConfigBuilder().getActiveProfileInterface();
|
||||
|
||||
ProfileSwitch profileSwitch = activeTreatments.getProfileSwitchFromHistory(time);
|
||||
if (profileSwitch != null) {
|
||||
if (profileSwitch.profileJson != null) {
|
||||
return customized ? profileSwitch.getCustomizedName() : profileSwitch.profileName;
|
||||
} else {
|
||||
ProfileStore profileStore = activeProfile.getProfile();
|
||||
if (profileStore != null) {
|
||||
Profile profile = profileStore.getSpecificProfile(profileSwitch.profileName);
|
||||
if (profile != null)
|
||||
return profileSwitch.profileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
return MainApp.gs(R.string.noprofileselected);
|
||||
}
|
||||
|
||||
public boolean isProfileValid(String from) {
|
||||
return getProfile() != null && getProfile().isValid(from);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Profile getProfile() {
|
||||
return getProfile(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public String getProfileUnits() {
|
||||
Profile profile = getProfile();
|
||||
return profile != null ? profile.getUnits() : Constants.MGDL;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Profile getProfile(long time) {
|
||||
TreatmentsInterface activeTreatments = TreatmentsPlugin.getPlugin();
|
||||
ProfileInterface activeProfile = MainApp.getConfigBuilder().getActiveProfileInterface();
|
||||
|
||||
//log.debug("Profile for: " + new Date(time).toLocaleString() + " : " + getProfileName(time));
|
||||
ProfileSwitch profileSwitch = activeTreatments.getProfileSwitchFromHistory(time);
|
||||
if (profileSwitch != null) {
|
||||
if (profileSwitch.profileJson != null) {
|
||||
return profileSwitch.getProfileObject();
|
||||
} else if (activeProfile.getProfile() != null) {
|
||||
Profile profile = activeProfile.getProfile().getSpecificProfile(profileSwitch.profileName);
|
||||
if (profile != null)
|
||||
return profile;
|
||||
}
|
||||
}
|
||||
if (activeTreatments.getProfileSwitchesFromHistory().size() > 0) {
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("CatchedError")
|
||||
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
|
||||
.putCustomAttribute("version", BuildConfig.VERSION)
|
||||
.putCustomAttribute("time", time)
|
||||
.putCustomAttribute("getProfileSwitchesFromHistory", activeTreatments.getProfileSwitchesFromHistory().toString())
|
||||
);
|
||||
}
|
||||
log.debug("getProfile at the end: returning null");
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -5,6 +5,7 @@ import com.squareup.otto.Bus;
|
|||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.Iob;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
|
@ -61,7 +62,7 @@ public abstract class InsulinOrefBasePlugin extends PluginBase implements Insuli
|
|||
}
|
||||
|
||||
public double getUserDefinedDia() {
|
||||
return MainApp.getConfigBuilder().getProfile() != null ? MainApp.getConfigBuilder().getProfile().getDia() : MIN_DIA;
|
||||
return ProfileFunctions.getInstance().getProfile() != null ? ProfileFunctions.getInstance().getProfile().getDia() : MIN_DIA;
|
||||
}
|
||||
|
||||
public Iob iobCalcForTreatment(Treatment treatment, long time) {
|
||||
|
|
|
@ -13,6 +13,7 @@ import info.nightscout.androidaps.R;
|
|||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSSMB.SMBDefaults;
|
||||
import info.nightscout.androidaps.plugins.Overview.graphExtensions.DataPointWithLabelInterface;
|
||||
import info.nightscout.androidaps.plugins.Overview.graphExtensions.PointsWithLabelGraphSeries;
|
||||
|
@ -45,7 +46,7 @@ public class AutosensData implements DataPointWithLabelInterface {
|
|||
remaining = t.carbs;
|
||||
if (SensitivityAAPSPlugin.getPlugin().isEnabled(PluginType.SENSITIVITY) || SensitivityWeightedAveragePlugin.getPlugin().isEnabled(PluginType.SENSITIVITY)) {
|
||||
double maxAbsorptionHours = SP.getDouble(R.string.key_absorption_maxtime, Constants.DEFAULT_MAX_ABSORPTION_TIME);
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile(t.date);
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile(t.date);
|
||||
double sens = Profile.toMgdl(profile.getIsf(t.date), profile.getUnits());
|
||||
double ic = profile.getIc(t.date);
|
||||
min5minCarbImpact = t.carbs / (maxAbsorptionHours * 60 / 5) * sens / ic;
|
||||
|
|
|
@ -33,6 +33,7 @@ import info.nightscout.androidaps.interfaces.PluginDescription;
|
|||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
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.IobCobCalculator.events.EventNewHistoryData;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSSMB.OpenAPSSMBPlugin;
|
||||
import info.nightscout.androidaps.plugins.Sensitivity.SensitivityOref1Plugin;
|
||||
|
@ -302,7 +303,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
|||
}
|
||||
|
||||
public long calculateDetectionStart(long from, boolean limitDataToOldestAvailable) {
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile(from);
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile(from);
|
||||
double dia = Constants.defaultDIA;
|
||||
if (profile != null) dia = profile.getDia();
|
||||
|
||||
|
@ -599,7 +600,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
|||
}
|
||||
if (MainApp.getConfigBuilder() == null)
|
||||
return; // app still initializing
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
if (profile == null)
|
||||
return; // app still initializing
|
||||
dia = profile.getDia();
|
||||
|
|
|
@ -26,6 +26,7 @@ import info.nightscout.androidaps.db.BgReading;
|
|||
import info.nightscout.androidaps.db.TempTarget;
|
||||
import info.nightscout.androidaps.events.Event;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventIobCalculationProgress;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSSMB.SMBDefaults;
|
||||
|
@ -79,7 +80,7 @@ public class IobCobOref1Thread extends Thread {
|
|||
log.debug("Aborting calculation thread (ConfigBuilder not ready): " + from);
|
||||
return; // app still initializing
|
||||
}
|
||||
if (!MainApp.getConfigBuilder().isProfileValid("IobCobThread")) {
|
||||
if (!ProfileFunctions.getInstance().isProfileValid("IobCobThread")) {
|
||||
if (L.isEnabled(L.AUTOSENS))
|
||||
log.debug("Aborting calculation thread (No profile): " + from);
|
||||
return; // app still initializing
|
||||
|
@ -129,7 +130,7 @@ public class IobCobOref1Thread extends Thread {
|
|||
continue;
|
||||
}
|
||||
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile(bgTime);
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile(bgTime);
|
||||
if (profile == null) {
|
||||
if (L.isEnabled(L.AUTOSENS))
|
||||
log.debug("Aborting calculation thread (no profile): " + from);
|
||||
|
|
|
@ -24,6 +24,7 @@ import info.nightscout.androidaps.db.BgReading;
|
|||
import info.nightscout.androidaps.events.Event;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventIobCalculationProgress;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSSMB.SMBDefaults;
|
||||
|
@ -78,7 +79,7 @@ public class IobCobThread extends Thread {
|
|||
log.debug("Aborting calculation thread (ConfigBuilder not ready): " + from);
|
||||
return; // app still initializing
|
||||
}
|
||||
if (!MainApp.getConfigBuilder().isProfileValid("IobCobThread")) {
|
||||
if (!ProfileFunctions.getInstance().isProfileValid("IobCobThread")) {
|
||||
if (L.isEnabled(L.AUTOSENS))
|
||||
log.debug("Aborting calculation thread (No profile): " + from);
|
||||
return; // app still initializing
|
||||
|
@ -128,7 +129,7 @@ public class IobCobThread extends Thread {
|
|||
continue;
|
||||
}
|
||||
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile(bgTime);
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile(bgTime);
|
||||
if (profile == null) {
|
||||
if (L.isEnabled(L.AUTOSENS))
|
||||
log.debug("Aborting calculation thread (no profile): " + from);
|
||||
|
|
|
@ -39,6 +39,7 @@ import info.nightscout.androidaps.interfaces.PluginType;
|
|||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
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.IobCobCalculator.events.EventAutosensCalculationFinished;
|
||||
import info.nightscout.androidaps.plugins.Loop.events.EventLoopSetLastRunGui;
|
||||
import info.nightscout.androidaps.plugins.Loop.events.EventLoopUpdateGui;
|
||||
|
@ -271,9 +272,9 @@ public class LoopPlugin extends PluginBase {
|
|||
if (!isEnabled(PluginType.LOOP))
|
||||
return;
|
||||
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
|
||||
if (!MainApp.getConfigBuilder().isProfileValid("Loop")) {
|
||||
if (!ProfileFunctions.getInstance().isProfileValid("Loop")) {
|
||||
if (L.isEnabled(L.APS))
|
||||
log.debug(MainApp.gs(R.string.noprofileselected));
|
||||
MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.gs(R.string.noprofileselected)));
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.Locale;
|
|||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.services.Intents;
|
||||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
|
@ -83,7 +84,7 @@ public class NSUpload {
|
|||
if (useAbsolute) {
|
||||
TemporaryBasal t = temporaryBasal.clone();
|
||||
t.isAbsolute = true;
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
if (profile != null) {
|
||||
t.absoluteRate = profile.getBasal(temporaryBasal.date) * temporaryBasal.percentRate / 100d;
|
||||
uploadTempBasalStartAbsolute(t, null);
|
||||
|
@ -195,8 +196,8 @@ public class NSUpload {
|
|||
}
|
||||
|
||||
public static void uploadDeviceStatus() {
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
String profileName = MainApp.getConfigBuilder().getProfileName();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
String profileName = ProfileFunctions.getInstance().getProfileName();
|
||||
|
||||
if (profile == null || profileName == null) {
|
||||
log.error("Profile is null. Skipping upload");
|
||||
|
@ -303,7 +304,7 @@ public class NSUpload {
|
|||
|
||||
public static void uploadTempTarget(TempTarget tempTarget) {
|
||||
try {
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
|
||||
if (profile == null) {
|
||||
log.error("Profile is null. Skipping upload");
|
||||
|
|
|
@ -21,6 +21,7 @@ import info.nightscout.androidaps.interfaces.PluginType;
|
|||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
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.IobCobCalculator.AutosensData;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||
|
@ -97,7 +98,7 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
|
|||
determineBasalAdapterAMAJS = new DetermineBasalAdapterAMAJS(new ScriptReader(MainApp.instance().getBaseContext()));
|
||||
|
||||
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
|
||||
if (profile == null) {
|
||||
|
|
|
@ -21,6 +21,7 @@ import info.nightscout.androidaps.interfaces.PluginType;
|
|||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
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.Loop.APSResult;
|
||||
import info.nightscout.androidaps.plugins.Loop.ScriptReader;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui;
|
||||
|
@ -96,7 +97,7 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
|
|||
determineBasalAdapterMAJS = new DetermineBasalAdapterMAJS(new ScriptReader(MainApp.instance().getBaseContext()));
|
||||
|
||||
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
|
||||
if (profile == null) {
|
||||
|
|
|
@ -22,6 +22,7 @@ import info.nightscout.androidaps.interfaces.PluginType;
|
|||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
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.IobCobCalculator.AutosensData;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||
|
@ -100,7 +101,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface {
|
|||
determineBasalAdapterSMBJS = new DetermineBasalAdapterSMBJS(new ScriptReader(MainApp.instance().getBaseContext()));
|
||||
|
||||
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
|
||||
if (profile == null) {
|
||||
|
|
|
@ -23,6 +23,7 @@ import info.nightscout.androidaps.MainApp;
|
|||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.GlucoseStatus;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.utils.FabricPrivacy;
|
||||
import info.nightscout.utils.NumberPicker;
|
||||
import info.nightscout.utils.SafeParse;
|
||||
|
@ -63,7 +64,7 @@ public class CalibrationDialog extends DialogFragment implements View.OnClickLis
|
|||
view.findViewById(R.id.ok).setOnClickListener(this);
|
||||
view.findViewById(R.id.cancel).setOnClickListener(this);
|
||||
|
||||
String units = MainApp.getConfigBuilder().getProfileUnits();
|
||||
String units = ProfileFunctions.getInstance().getProfileUnits();
|
||||
Double bg = Profile.fromMgdlToUnits(GlucoseStatus.getGlucoseStatusData() != null ? GlucoseStatus.getGlucoseStatusData().glucose : 0d, units);
|
||||
|
||||
bgNumber = (NumberPicker) view.findViewById(R.id.overview_calibration_bg);
|
||||
|
|
|
@ -21,6 +21,7 @@ import android.widget.RadioButton;
|
|||
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -309,7 +310,7 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, C
|
|||
}
|
||||
okClicked = true;
|
||||
try {
|
||||
final Profile currentProfile = MainApp.getConfigBuilder().getProfile();
|
||||
final Profile currentProfile = ProfileFunctions.getInstance().getProfile();
|
||||
if (currentProfile == null) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ import info.nightscout.androidaps.db.Source;
|
|||
import info.nightscout.androidaps.db.TempTarget;
|
||||
import info.nightscout.androidaps.interfaces.Constraint;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||
import info.nightscout.androidaps.queue.Callback;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
|
@ -208,7 +209,7 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener
|
|||
okClicked = true;
|
||||
|
||||
try {
|
||||
Profile currentProfile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile currentProfile = ProfileFunctions.getInstance().getProfile();
|
||||
if (currentProfile == null)
|
||||
return;
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ import info.nightscout.androidaps.events.EventRefreshOverview;
|
|||
import info.nightscout.androidaps.interfaces.Constraint;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.CobInfo;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished;
|
||||
|
@ -325,7 +326,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
|||
return;
|
||||
}
|
||||
okClicked = true;
|
||||
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
final Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
|
||||
if (profile != null && (calculatedTotalInsulin > 0d || calculatedCarbs > 0d)) {
|
||||
String confirmMessage = MainApp.gs(R.string.entertreatmentquestion);
|
||||
|
@ -432,7 +433,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
|||
}
|
||||
|
||||
private void initDialog() {
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
ProfileStore profileStore = MainApp.getConfigBuilder().getActiveProfileInterface() != null ? MainApp.getConfigBuilder().getActiveProfileInterface().getProfile() : null;
|
||||
|
||||
if (profile == null || profileStore == null) {
|
||||
|
@ -483,7 +484,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
|||
String selectedAlternativeProfile = profileSpinner.getSelectedItem().toString();
|
||||
Profile specificProfile;
|
||||
if (selectedAlternativeProfile.equals(MainApp.gs(R.string.active)))
|
||||
specificProfile = MainApp.getConfigBuilder().getProfile();
|
||||
specificProfile = ProfileFunctions.getInstance().getProfile();
|
||||
else
|
||||
specificProfile = profileStore.getSpecificProfile(selectedAlternativeProfile);
|
||||
|
||||
|
|
|
@ -85,6 +85,7 @@ import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
|
|||
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
|
||||
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.ConstraintsObjectives.ObjectivesPlugin;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.CobInfo;
|
||||
|
@ -453,7 +454,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
if (v == apsModeView) {
|
||||
final LoopPlugin loopPlugin = LoopPlugin.getPlugin();
|
||||
final PumpDescription pumpDescription = ConfigBuilderPlugin.getActivePump().getPumpDescription();
|
||||
if (loopPlugin == null || !MainApp.getConfigBuilder().isProfileValid("ContexMenuCreation"))
|
||||
if (!ProfileFunctions.getInstance().isProfileValid("ContexMenuCreation"))
|
||||
return;
|
||||
menu.setHeaderTitle(MainApp.gs(R.string.loop));
|
||||
if (loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||
|
@ -496,7 +497,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
|
||||
@Override
|
||||
public boolean onContextItemSelected(MenuItem item) {
|
||||
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
final Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
if (profile == null)
|
||||
return true;
|
||||
final LoopPlugin loopPlugin = LoopPlugin.getPlugin();
|
||||
|
@ -637,7 +638,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
public void onClick(View v) {
|
||||
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();
|
||||
String units = ProfileFunctions.getInstance().getProfileUnits();
|
||||
|
||||
FragmentManager manager = getFragmentManager();
|
||||
// try to fix https://fabric.io/nightscout3/android/apps/info.nightscout.androidaps/issues/5aca7a1536c7b23527eb4be7?time=last-seven-days
|
||||
|
@ -725,7 +726,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
}
|
||||
|
||||
private void onClickAcceptTemp() {
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
Context context = getContext();
|
||||
|
||||
if (context == null) return;
|
||||
|
@ -767,7 +768,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
|
||||
void onClickQuickwizard() {
|
||||
final BgReading actualBg = DatabaseHelper.actualBg();
|
||||
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
final Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
final TempTarget tempTarget = TreatmentsPlugin.getPlugin().getTempTargetFromHistory();
|
||||
|
||||
final QuickWizardEntry quickWizardEntry = OverviewPlugin.getPlugin().quickWizard.getActive();
|
||||
|
@ -1048,7 +1049,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
pumpStatusLayout.setVisibility(View.GONE);
|
||||
loopStatusLayout.setVisibility(View.GONE);
|
||||
|
||||
if (!MainApp.getConfigBuilder().isProfileValid("Overview")) {
|
||||
if (!ProfileFunctions.getInstance().isProfileValid("Overview")) {
|
||||
pumpStatusView.setText(R.string.noprofileset);
|
||||
pumpStatusLayout.setVisibility(View.VISIBLE);
|
||||
return;
|
||||
|
@ -1061,7 +1062,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
|
||||
final PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
|
||||
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
final Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
|
||||
final String units = profile.getUnits();
|
||||
final double lowLine = OverviewPlugin.getPlugin().determineLowLine(units);
|
||||
|
@ -1245,7 +1246,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
extendedBolusView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
activeProfileView.setText(MainApp.getConfigBuilder().getProfileName());
|
||||
activeProfileView.setText(ProfileFunctions.getInstance().getProfileName());
|
||||
activeProfileView.setBackgroundColor(Color.GRAY);
|
||||
|
||||
// QuickWizard button
|
||||
|
|
|
@ -16,6 +16,7 @@ import info.nightscout.androidaps.interfaces.PluginBase;
|
|||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||
import info.nightscout.androidaps.plugins.Overview.notifications.NotificationStore;
|
||||
|
@ -92,7 +93,7 @@ public class OverviewPlugin extends PluginBase {
|
|||
}
|
||||
|
||||
public double determineLowLine() {
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
if (profile == null) {
|
||||
return bgTargetLow;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import info.nightscout.androidaps.db.ProfileSwitch;
|
|||
import info.nightscout.androidaps.db.TempTarget;
|
||||
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.IobCobCalculator.AutosensData;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.BasalData;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||
|
@ -63,7 +64,7 @@ public class GraphData {
|
|||
private IobCobCalculatorPlugin iobCobCalculatorPlugin;
|
||||
|
||||
public GraphData(GraphView graph, IobCobCalculatorPlugin iobCobCalculatorPlugin) {
|
||||
units = MainApp.getConfigBuilder().getProfileUnits();
|
||||
units = ProfileFunctions.getInstance().getProfileUnits();
|
||||
this.graph = graph;
|
||||
this.iobCobCalculatorPlugin = iobCobCalculatorPlugin;
|
||||
}
|
||||
|
@ -144,7 +145,7 @@ public class GraphData {
|
|||
double lastBaseBasal = 0;
|
||||
double lastTempBasal = 0;
|
||||
for (long time = fromTime; time < toTime; time += 60 * 1000L) {
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile(time);
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile(time);
|
||||
if (profile == null) continue;
|
||||
BasalData basalData = iobCobCalculatorPlugin.getBasalData(profile, time);
|
||||
double baseBasalValue = basalData.basal;
|
||||
|
@ -348,7 +349,7 @@ public class GraphData {
|
|||
Scale iobScale = new Scale();
|
||||
|
||||
for (long time = fromTime; time <= toTime; time += 5 * 60 * 1000L) {
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile(time);
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile(time);
|
||||
double iob = 0d;
|
||||
if (profile != null)
|
||||
iob = iobCobCalculatorPlugin.calculateFromTreatmentsAndTempsSynchronized(time, profile).iob;
|
||||
|
|
|
@ -37,6 +37,7 @@ 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.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
|
@ -108,9 +109,9 @@ public class PersistentNotificationPlugin extends PluginBase {
|
|||
|
||||
String line1 = "";
|
||||
|
||||
if (MainApp.getConfigBuilder().getActiveProfileInterface() == null || !MainApp.getConfigBuilder().isProfileValid("Notificiation"))
|
||||
if (MainApp.getConfigBuilder().getActiveProfileInterface() == null || !ProfileFunctions.getInstance().isProfileValid("Notificiation"))
|
||||
return null;
|
||||
String units = MainApp.getConfigBuilder().getProfileUnits();
|
||||
String units = ProfileFunctions.getInstance().getProfileUnits();
|
||||
|
||||
|
||||
BgReading lastBG = DatabaseHelper.lastBg();
|
||||
|
@ -147,7 +148,7 @@ public class PersistentNotificationPlugin extends PluginBase {
|
|||
String line3 = DecimalFormatter.to2Decimal(ConfigBuilderPlugin.getActivePump().getBaseBasalRate()) + " U/h";
|
||||
|
||||
|
||||
line3 += " - " + MainApp.getConfigBuilder().getProfileName();
|
||||
line3 += " - " + ProfileFunctions.getInstance().getProfileName();
|
||||
|
||||
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx, CHANNEL_ID);
|
||||
|
|
|
@ -24,6 +24,7 @@ import info.nightscout.androidaps.data.Profile;
|
|||
import info.nightscout.androidaps.data.ProfileStore;
|
||||
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
|
||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.ProfileNS.events.EventNSProfileUpdateGUI;
|
||||
import info.nightscout.androidaps.plugins.Treatments.fragments.ProfileGraph;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
|
@ -92,7 +93,7 @@ public class NSProfileFragment extends SubscriberFragment {
|
|||
profileSpinner.setAdapter(adapter);
|
||||
// set selected to actual profile
|
||||
for (int p = 0; p < profileList.size(); p++) {
|
||||
if (profileList.get(p).equals(MainApp.getConfigBuilder().getProfileName()))
|
||||
if (profileList.get(p).equals(ProfileFunctions.getInstance().getProfileName()))
|
||||
profileSpinner.setSelection(p);
|
||||
}
|
||||
noProfile.setVisibility(View.GONE);
|
||||
|
|
|
@ -43,6 +43,7 @@ import info.nightscout.androidaps.interfaces.PumpInterface;
|
|||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
||||
|
@ -1338,7 +1339,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
|||
|
||||
JSONObject extendedJson = new JSONObject();
|
||||
extendedJson.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION);
|
||||
extendedJson.put("ActiveProfile", MainApp.getConfigBuilder().getProfileName());
|
||||
extendedJson.put("ActiveProfile", ProfileFunctions.getInstance().getProfileName());
|
||||
PumpState ps = pump.state;
|
||||
if (ps.tbrActive) {
|
||||
extendedJson.put("TempBasalAbsoluteRate", ps.basalRate);
|
||||
|
|
|
@ -33,6 +33,7 @@ import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
|||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
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.PumpDanaR.comm.RecordTypes;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRSyncStatus;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
|
||||
|
@ -197,7 +198,7 @@ public class DanaRHistoryActivity extends Activity {
|
|||
clearCardView();
|
||||
}
|
||||
});
|
||||
profile = MainApp.getConfigBuilder().getProfile();
|
||||
profile = ProfileFunctions.getInstance().getProfile();
|
||||
if (profile == null) {
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.noprofile));
|
||||
finish();
|
||||
|
|
|
@ -14,6 +14,7 @@ import info.nightscout.androidaps.data.Profile;
|
|||
import info.nightscout.androidaps.db.CareportalEvent;
|
||||
import info.nightscout.androidaps.db.DanaRHistoryRecord;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRSyncStatus;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
|
@ -182,7 +183,7 @@ public class DanaRNSHistorySync {
|
|||
log.debug("Syncing glucose record " + record.recordValue + " " + DateUtil.toISOString(record.recordDate));
|
||||
nsrec.put(DANARSIGNATURE, record.bytes);
|
||||
nsrec.put("eventType", "BG Check");
|
||||
nsrec.put("glucose", Profile.fromMgdlToUnits(record.recordValue, MainApp.getConfigBuilder().getProfileUnits()));
|
||||
nsrec.put("glucose", Profile.fromMgdlToUnits(record.recordValue, ProfileFunctions.getInstance().getProfileUnits()));
|
||||
nsrec.put("glucoseType", "Finger");
|
||||
nsrec.put("created_at", DateUtil.toISOString(record.recordDate));
|
||||
nsrec.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name));
|
||||
|
|
|
@ -23,6 +23,7 @@ import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
|||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
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.Overview.Dialogs.BolusProgressDialog;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
||||
|
@ -167,7 +168,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
|||
long now = System.currentTimeMillis();
|
||||
mDanaRPump.lastConnection = now;
|
||||
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||
if (profile != null && Math.abs(mDanaRPump.currentBasal - profile.getBasal()) >= pump.getPumpDescription().basalStep) {
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings)));
|
||||
|
|
|
@ -23,6 +23,7 @@ import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
|||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
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.Overview.Dialogs.BolusProgressDialog;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||
|
@ -171,7 +172,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
|||
long now = System.currentTimeMillis();
|
||||
mDanaRPump.lastConnection = now;
|
||||
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||
if (profile != null && Math.abs(mDanaRPump.currentBasal - profile.getBasal()) >= pump.getPumpDescription().basalStep) {
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings)));
|
||||
|
|
|
@ -41,6 +41,7 @@ import info.nightscout.androidaps.interfaces.PumpInterface;
|
|||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.DetailedBolusInfoStorage;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||
|
@ -745,7 +746,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
|||
}
|
||||
extended.put("BaseBasalRate", getBaseBasalRate());
|
||||
try {
|
||||
extended.put("ActiveProfile", MainApp.getConfigBuilder().getProfileName());
|
||||
extended.put("ActiveProfile", ProfileFunctions.getInstance().getProfileName());
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
|||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
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.Overview.Dialogs.BolusProgressDialog;
|
||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||
|
@ -142,7 +143,7 @@ public class DanaRSService extends Service {
|
|||
|
||||
danaRPump.lastConnection = System.currentTimeMillis();
|
||||
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||
if (profile != null && Math.abs(danaRPump.currentBasal - profile.getBasal()) >= pump.getPumpDescription().basalStep) {
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings)));
|
||||
|
|
|
@ -24,6 +24,7 @@ import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
|||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
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.Overview.Dialogs.BolusProgressDialog;
|
||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||
|
@ -192,7 +193,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
|||
|
||||
mDanaRPump.lastConnection = System.currentTimeMillis();
|
||||
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||
if (profile != null && Math.abs(mDanaRPump.currentBasal - profile.getBasal()) >= pump.getPumpDescription().basalStep) {
|
||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings)));
|
||||
|
|
|
@ -33,6 +33,7 @@ import info.nightscout.androidaps.interfaces.PumpDescription;
|
|||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
||||
|
@ -671,7 +672,7 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
|
|||
status.put("timestamp", DateUtil.toISOString(connector.getLastContactTime()));
|
||||
extended.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION);
|
||||
try {
|
||||
extended.put("ActiveProfile", MainApp.getConfigBuilder().getProfileName());
|
||||
extended.put("ActiveProfile", ProfileFunctions.getInstance().getProfileName());
|
||||
} catch (Exception e) {
|
||||
}
|
||||
TemporaryBasal tb = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(now);
|
||||
|
|
|
@ -25,6 +25,7 @@ import info.nightscout.androidaps.interfaces.PluginType;
|
|||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
||||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||
|
@ -191,7 +192,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
|||
|
||||
@Override
|
||||
public double getBaseBasalRate() {
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
if (profile != null)
|
||||
return profile.getBasal();
|
||||
else
|
||||
|
|
|
@ -17,6 +17,7 @@ import info.nightscout.androidaps.db.CareportalEvent;
|
|||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||
|
@ -59,7 +60,7 @@ public class SensitivityAAPSPlugin extends AbstractSensitivityPlugin {
|
|||
if (age.equals(MainApp.gs(R.string.key_child))) defaultHours = 4;
|
||||
int hoursForDetection = SP.getInt(R.string.key_openapsama_autosens_period, defaultHours);
|
||||
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
|
||||
if (profile == null) {
|
||||
log.error("No profile");
|
||||
|
|
|
@ -17,6 +17,7 @@ import info.nightscout.androidaps.db.CareportalEvent;
|
|||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||
|
@ -54,7 +55,7 @@ public class SensitivityOref0Plugin extends AbstractSensitivityPlugin {
|
|||
int hoursForDetection = 24;
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
|
||||
if (profile == null) {
|
||||
log.error("No profile");
|
||||
|
|
|
@ -17,6 +17,7 @@ import info.nightscout.androidaps.db.CareportalEvent;
|
|||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||
|
@ -53,7 +54,7 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin {
|
|||
// dependency, this should be avoided
|
||||
LongSparseArray<AutosensData> autosensDataTable = iobCobCalculatorPlugin.getAutosensDataTable();
|
||||
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
|
||||
if (profile == null) {
|
||||
log.error("No profile");
|
||||
|
|
|
@ -15,6 +15,7 @@ import info.nightscout.androidaps.db.CareportalEvent;
|
|||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||
|
@ -71,7 +72,7 @@ public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin
|
|||
}
|
||||
|
||||
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
if (profile == null) {
|
||||
if (L.isEnabled(L.AUTOSENS))
|
||||
log.debug("No profile available");
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.util.List;
|
|||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.services.Intents;
|
||||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||
import info.nightscout.androidaps.data.GlucoseStatus;
|
||||
|
@ -207,7 +208,7 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
BgReading actualBG = DatabaseHelper.actualBg();
|
||||
BgReading lastBG = DatabaseHelper.lastBg();
|
||||
|
||||
String units = MainApp.getConfigBuilder().getProfileUnits();
|
||||
String units = ProfileFunctions.getInstance().getProfileUnits();
|
||||
|
||||
if (actualBG != null) {
|
||||
reply = MainApp.gs(R.string.sms_actualbg) + " " + actualBG.valueToUnitsToString(units) + ", ";
|
||||
|
@ -378,7 +379,7 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
}
|
||||
} else {
|
||||
tempBasal = SafeParse.stringToDouble(splited[1]);
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
if (profile == null) {
|
||||
reply = MainApp.gs(R.string.noprofile);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
|
@ -471,7 +472,7 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
} else if (tempBasalWaitingForConfirmation != null && !tempBasalWaitingForConfirmation.processed &&
|
||||
tempBasalWaitingForConfirmation.confirmCode.equals(splited[0]) && System.currentTimeMillis() - tempBasalWaitingForConfirmation.date.getTime() < Constants.SMS_CONFIRM_TIMEOUT) {
|
||||
tempBasalWaitingForConfirmation.processed = true;
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
if (profile != null)
|
||||
ConfigBuilderPlugin.getCommandQueue().tempBasalAbsolute(tempBasalWaitingForConfirmation.tempBasal, 30, true, profile, new Callback() {
|
||||
@Override
|
||||
|
|
|
@ -39,6 +39,7 @@ import info.nightscout.androidaps.interfaces.PluginType;
|
|||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||
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.IobCobCalculator.AutosensData;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity;
|
||||
|
@ -113,8 +114,8 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
|||
if (L.isEnabled(L.DATATREATMENTS))
|
||||
log.debug("initializeTreatmentData");
|
||||
double dia = Constants.defaultDIA;
|
||||
if (MainApp.getConfigBuilder() != null && MainApp.getConfigBuilder().getProfile() != null)
|
||||
dia = MainApp.getConfigBuilder().getProfile().getDia();
|
||||
if (MainApp.getConfigBuilder() != null && ProfileFunctions.getInstance().getProfile() != null)
|
||||
dia = ProfileFunctions.getInstance().getProfile().getDia();
|
||||
long fromMills = (long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + dia));
|
||||
synchronized (treatments) {
|
||||
treatments.clear();
|
||||
|
@ -126,8 +127,8 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
|||
if (L.isEnabled(L.DATATREATMENTS))
|
||||
log.debug("initializeTempBasalData");
|
||||
double dia = Constants.defaultDIA;
|
||||
if (MainApp.getConfigBuilder() != null && MainApp.getConfigBuilder().getProfile() != null)
|
||||
dia = MainApp.getConfigBuilder().getProfile().getDia();
|
||||
if (MainApp.getConfigBuilder() != null && ProfileFunctions.getInstance().getProfile() != null)
|
||||
dia = ProfileFunctions.getInstance().getProfile().getDia();
|
||||
long fromMills = (long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + dia));
|
||||
|
||||
synchronized (tempBasals) {
|
||||
|
@ -140,8 +141,8 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
|||
if (L.isEnabled(L.DATATREATMENTS))
|
||||
log.debug("initializeExtendedBolusData");
|
||||
double dia = Constants.defaultDIA;
|
||||
if (MainApp.getConfigBuilder() != null && MainApp.getConfigBuilder().getProfile() != null)
|
||||
dia = MainApp.getConfigBuilder().getProfile().getDia();
|
||||
if (MainApp.getConfigBuilder() != null && ProfileFunctions.getInstance().getProfile() != null)
|
||||
dia = ProfileFunctions.getInstance().getProfile().getDia();
|
||||
long fromMills = (long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + dia));
|
||||
|
||||
synchronized (extendedBoluses) {
|
||||
|
@ -176,7 +177,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
|||
public IobTotal getCalculationToTimeTreatments(long time) {
|
||||
IobTotal total = new IobTotal(time);
|
||||
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
if (profile == null)
|
||||
return total;
|
||||
|
||||
|
@ -224,7 +225,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
|||
public MealData getMealData() {
|
||||
MealData result = new MealData();
|
||||
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
if (profile == null) return result;
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
|
@ -410,7 +411,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
|||
|
||||
@Override
|
||||
public void updateTotalIOBTempBasals() {
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
if (profile != null)
|
||||
lastTempBasalsCalculation = getCalculationToTimeTempBasals(DateUtil.now(), profile);
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.List;
|
|||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.services.Intents;
|
||||
import info.nightscout.androidaps.data.Iob;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
|
@ -69,7 +70,7 @@ public class TreatmentsBolusFragment extends SubscriberFragment implements View.
|
|||
|
||||
@Override
|
||||
public void onBindViewHolder(TreatmentsViewHolder holder, int position) {
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
if (profile == null)
|
||||
return;
|
||||
Treatment t = treatments.get(position);
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.List;
|
|||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.services.Intents;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.db.ProfileSwitch;
|
||||
|
@ -64,7 +65,7 @@ public class TreatmentsProfileSwitchFragment extends SubscriberFragment implemen
|
|||
|
||||
@Override
|
||||
public void onBindViewHolder(ProfileSwitchViewHolder holder, int position) {
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
if (profile == null) return;
|
||||
ProfileSwitch profileSwitch = profileSwitchList.get(position);
|
||||
holder.ph.setVisibility(profileSwitch.source == Source.PUMP ? View.VISIBLE : View.GONE);
|
||||
|
|
|
@ -21,6 +21,7 @@ import com.squareup.otto.Subscribe;
|
|||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.services.Intents;
|
||||
import info.nightscout.androidaps.data.Intervals;
|
||||
import info.nightscout.androidaps.db.Source;
|
||||
|
@ -65,7 +66,7 @@ public class TreatmentsTempTargetFragment extends SubscriberFragment implements
|
|||
|
||||
@Override
|
||||
public void onBindViewHolder(TempTargetsViewHolder holder, int position) {
|
||||
String units = MainApp.getConfigBuilder().getProfileUnits();
|
||||
String units = ProfileFunctions.getInstance().getProfileUnits();
|
||||
TempTarget tempTarget = tempTargetList.getReversed(position);
|
||||
holder.ph.setVisibility(tempTarget.source == Source.PUMP ? View.VISIBLE : View.GONE);
|
||||
holder.ns.setVisibility(NSUpload.isIdValid(tempTarget._id) ? View.VISIBLE : View.GONE);
|
||||
|
|
|
@ -28,6 +28,7 @@ import info.nightscout.androidaps.db.TemporaryBasal;
|
|||
import info.nightscout.androidaps.events.EventNewBG;
|
||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue;
|
||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
|
@ -84,7 +85,7 @@ public class TreatmentsTemporaryBasalsFragment extends SubscriberFragment {
|
|||
}
|
||||
holder.duration.setText(DecimalFormatter.to0Decimal(tempBasal.durationInMinutes, " min"));
|
||||
if (tempBasal.isAbsolute) {
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile(tempBasal.date);
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile(tempBasal.date);
|
||||
if (profile != null) {
|
||||
holder.absolute.setText(DecimalFormatter.to0Decimal(tempBasal.tempBasalConvertedToAbsolute(tempBasal.date, profile), " U/h"));
|
||||
holder.percent.setText("");
|
||||
|
@ -99,7 +100,7 @@ public class TreatmentsTemporaryBasalsFragment extends SubscriberFragment {
|
|||
holder.realDuration.setText(DecimalFormatter.to0Decimal(tempBasal.getRealDuration(), " min"));
|
||||
long now = DateUtil.now();
|
||||
IobTotal iob = new IobTotal(now);
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile(now);
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile(now);
|
||||
if (profile != null)
|
||||
iob = tempBasal.iobCalc(now, profile);
|
||||
holder.iob.setText(DecimalFormatter.to2Decimal(iob.basaliob, " U"));
|
||||
|
|
|
@ -32,6 +32,7 @@ import info.nightscout.androidaps.interfaces.PumpInterface;
|
|||
import info.nightscout.androidaps.plugins.Actions.dialogs.FillDialog;
|
||||
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.CobInfo;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||
import info.nightscout.androidaps.plugins.Loop.APSResult;
|
||||
|
@ -134,7 +135,7 @@ public class ActionStringHandler {
|
|||
///////////////////////////////////////////////////////// TEMPTARGET
|
||||
boolean isMGDL = Boolean.parseBoolean(act[1]);
|
||||
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
if (profile == null) {
|
||||
sendError("No profile found!");
|
||||
return;
|
||||
|
@ -203,7 +204,7 @@ public class ActionStringHandler {
|
|||
boolean useTrend = SP.getBoolean(R.string.key_wearwizard_trend, false);
|
||||
int percentage = Integer.parseInt(act[2]);
|
||||
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
if (profile == null) {
|
||||
sendError("No profile found!");
|
||||
return;
|
||||
|
@ -363,7 +364,7 @@ public class ActionStringHandler {
|
|||
|
||||
private static String generateTDDMessage(List<TDD> historyList, List<TDD> dummies) {
|
||||
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
|
||||
if (profile == null) {
|
||||
return "No profile loaded :(";
|
||||
|
@ -517,7 +518,7 @@ public class ActionStringHandler {
|
|||
if (!Config.APS) {
|
||||
return "Targets only apply in APS mode!";
|
||||
}
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
if (profile == null) {
|
||||
return "No profile set :(";
|
||||
}
|
||||
|
@ -541,7 +542,7 @@ public class ActionStringHandler {
|
|||
if (!Config.APS) {
|
||||
return "Only apply in APS mode!";
|
||||
}
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
if (profile == null) {
|
||||
return "No profile set :(";
|
||||
}
|
||||
|
@ -651,7 +652,7 @@ public class ActionStringHandler {
|
|||
if (timeshift < 0 || timeshift > 23) {
|
||||
msg += String.format(MainApp.gs(R.string.valueoutofrange), "Profile-Timeshift") + "\n";
|
||||
}
|
||||
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
final Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
|
||||
if (profile == null) {
|
||||
msg += MainApp.gs(R.string.notloadedplugins) + "\n";
|
||||
|
|
|
@ -37,6 +37,7 @@ import info.nightscout.androidaps.data.Profile;
|
|||
import info.nightscout.androidaps.db.BgReading;
|
||||
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.CobInfo;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
|
@ -223,7 +224,7 @@ public class WatchUpdaterService extends WearableListenerService implements
|
|||
}
|
||||
|
||||
private DataMap dataMapSingleBG(BgReading lastBG, GlucoseStatus glucoseStatus) {
|
||||
String units = MainApp.getConfigBuilder().getProfileUnits();
|
||||
String units = ProfileFunctions.getInstance().getProfileUnits();
|
||||
|
||||
Double lowLine = SafeParse.stringToDouble(mPrefs.getString("low_mark", "0"));
|
||||
Double highLine = SafeParse.stringToDouble(mPrefs.getString("high_mark", "0"));
|
||||
|
@ -363,7 +364,7 @@ public class WatchUpdaterService extends WearableListenerService implements
|
|||
ArrayList<DataMap> predictions = new ArrayList<>();
|
||||
|
||||
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
|
||||
if (profile == null) {
|
||||
return;
|
||||
|
@ -383,7 +384,7 @@ public class WatchUpdaterService extends WearableListenerService implements
|
|||
|
||||
if (tb1 != null) {
|
||||
tb_before = beginBasalValue;
|
||||
Profile profileTB = MainApp.getConfigBuilder().getProfile(runningTime);
|
||||
Profile profileTB = ProfileFunctions.getInstance().getProfile(runningTime);
|
||||
if (profileTB != null) {
|
||||
tb_amount = tb1.tempBasalConvertedToAbsolute(runningTime, profileTB);
|
||||
tb_start = runningTime;
|
||||
|
@ -392,7 +393,7 @@ public class WatchUpdaterService extends WearableListenerService implements
|
|||
|
||||
|
||||
for (; runningTime < now; runningTime += 5 * 60 * 1000) {
|
||||
Profile profileTB = MainApp.getConfigBuilder().getProfile(runningTime);
|
||||
Profile profileTB = ProfileFunctions.getInstance().getProfile(runningTime);
|
||||
//basal rate
|
||||
endBasalValue = profile.getBasal(runningTime);
|
||||
if (endBasalValue != beginBasalValue) {
|
||||
|
@ -444,7 +445,7 @@ public class WatchUpdaterService extends WearableListenerService implements
|
|||
temps.add(tempDatamap(tb_start, tb_before, now - 1 * 60 * 1000, endBasalValue, tb_amount));
|
||||
} else {
|
||||
//express currently running temp by painting it a bit into the future
|
||||
Profile profileNow = MainApp.getConfigBuilder().getProfile(now);
|
||||
Profile profileNow = ProfileFunctions.getInstance().getProfile(now);
|
||||
double currentAmount = tb2.tempBasalConvertedToAbsolute(now, profileNow);
|
||||
if (currentAmount != tb_amount) {
|
||||
temps.add(tempDatamap(tb_start, tb_before, now, tb_amount, tb_amount));
|
||||
|
@ -457,7 +458,7 @@ public class WatchUpdaterService extends WearableListenerService implements
|
|||
tb2 = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(now); //use "now" to express current situation
|
||||
if (tb2 != null) {
|
||||
//onset at the end
|
||||
Profile profileTB = MainApp.getConfigBuilder().getProfile(runningTime);
|
||||
Profile profileTB = ProfileFunctions.getInstance().getProfile(runningTime);
|
||||
double currentAmount = tb2.tempBasalConvertedToAbsolute(runningTime, profileTB);
|
||||
temps.add(tempDatamap(now - 1 * 60 * 1000, endBasalValue, runningTime + 5 * 60 * 1000, currentAmount, currentAmount));
|
||||
}
|
||||
|
@ -580,7 +581,7 @@ public class WatchUpdaterService extends WearableListenerService implements
|
|||
private void sendStatus() {
|
||||
|
||||
if (googleApiClient.isConnected()) {
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
String status = MainApp.gs(R.string.noprofile);
|
||||
String iobSum, iobDetail, cobString, currentBasal, bgiString;
|
||||
iobSum = iobDetail = cobString = currentBasal = bgiString = "";
|
||||
|
@ -699,7 +700,7 @@ public class WatchUpdaterService extends WearableListenerService implements
|
|||
|
||||
String basalStringResult;
|
||||
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
if (profile == null)
|
||||
return "";
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ 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.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.CobInfo;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||
|
@ -93,7 +94,7 @@ public class StatuslinePlugin extends PluginBase {
|
|||
private void sendStatus() {
|
||||
String status = ""; // sent once on disable
|
||||
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
|
||||
if (isEnabled(PluginType.GENERAL) && profile != null) {
|
||||
status = buildStatusString(profile);
|
||||
|
|
|
@ -22,6 +22,7 @@ import info.nightscout.androidaps.interfaces.Constraint;
|
|||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
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.Overview.Dialogs.BolusProgressDialog;
|
||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressHelperActivity;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
||||
|
@ -502,7 +503,7 @@ public class CommandQueue {
|
|||
|
||||
public boolean isThisProfileSet(Profile profile) {
|
||||
PumpInterface activePump = ConfigBuilderPlugin.getActivePump();
|
||||
Profile current = MainApp.getConfigBuilder().getProfile();
|
||||
Profile current = ProfileFunctions.getInstance().getProfile();
|
||||
if (activePump != null && current != null) {
|
||||
boolean result = activePump.isThisProfileSet(profile);
|
||||
if (!result) {
|
||||
|
|
|
@ -7,6 +7,7 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.os.PowerManager;
|
||||
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.utils.FabricPrivacy;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -54,7 +55,7 @@ public class KeepAliveReceiver extends BroadcastReceiver {
|
|||
|
||||
private void checkPump() {
|
||||
final PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
final Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
if (pump != null && profile != null) {
|
||||
Date lastConnection = pump.lastDataTime();
|
||||
boolean isStatusOutdated = lastConnection.getTime() + STATUS_UPDATE_FREQUENCY < System.currentTimeMillis();
|
||||
|
|
|
@ -27,6 +27,7 @@ import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialo
|
|||
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.ConstraintsObjectives.ObjectivesFragment;
|
||||
import info.nightscout.androidaps.plugins.ConstraintsObjectives.ObjectivesPlugin;
|
||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||
|
@ -306,8 +307,8 @@ public class SWDefinition {
|
|||
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
|
||||
newDialog.show(getActivity().getSupportFragmentManager(), "NewNSTreatmentDialog");
|
||||
}))
|
||||
.validator(() -> MainApp.getConfigBuilder().getProfile() != null)
|
||||
.visibility(() -> MainApp.getConfigBuilder().getProfile() == null)
|
||||
.validator(() -> ProfileFunctions.getInstance().getProfile() != null)
|
||||
.visibility(() -> ProfileFunctions.getInstance().getProfile() == null)
|
||||
)
|
||||
.add(new SWScreen(R.string.configbuilder_pump)
|
||||
.skippable(false)
|
||||
|
|
|
@ -13,6 +13,7 @@ import info.nightscout.androidaps.db.BgReading;
|
|||
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
||||
|
@ -80,7 +81,7 @@ public class LocalAlertUtils {
|
|||
//TODO: persist the actual time the pump is read and simplify the whole logic when to alarm
|
||||
|
||||
final PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
final Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||
if (pump != null && profile != null) {
|
||||
Date lastConnection = pump.lastDataTime();
|
||||
long earliestAlarmTime = lastConnection.getTime() + pumpUnreachableThreshold();
|
||||
|
|
|
@ -15,6 +15,7 @@ import java.util.List;
|
|||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.services.Intents;
|
||||
|
||||
/**
|
||||
|
@ -45,7 +46,7 @@ public class XdripCalibrations {
|
|||
Context context = MainApp.instance().getApplicationContext();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putDouble("glucose_number", bg);
|
||||
bundle.putString("units", MainApp.getConfigBuilder().getProfileUnits().equals(Constants.MGDL) ? "mgdl" : "mmol");
|
||||
bundle.putString("units", ProfileFunctions.getInstance().getProfileUnits().equals(Constants.MGDL) ? "mgdl" : "mmol");
|
||||
bundle.putLong("timestamp", System.currentTimeMillis());
|
||||
Intent intent = new Intent(Intents.ACTION_REMOTE_CALIBRATION);
|
||||
intent.putExtras(bundle);
|
||||
|
|
Loading…
Reference in a new issue