split iob in wizard dialog, fixies for no data in app
This commit is contained in:
parent
af904b24bb
commit
caa4f3402e
8 changed files with 145 additions and 65 deletions
|
@ -37,7 +37,7 @@
|
||||||
<ConfirmationsSetting value="0" id="Add" />
|
<ConfirmationsSetting value="0" id="Add" />
|
||||||
<ConfirmationsSetting value="0" id="Remove" />
|
<ConfirmationsSetting value="0" id="Remove" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package info.nightscout.androidaps;
|
package info.nightscout.androidaps;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.view.ViewPager;
|
import android.support.v4.view.ViewPager;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
@ -184,12 +185,17 @@ public class MainActivity extends AppCompatActivity {
|
||||||
return newList;
|
return newList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public static PluginBase getSpecificPlugin(Class pluginClass) {
|
public static PluginBase getSpecificPlugin(Class pluginClass) {
|
||||||
Iterator<PluginBase> it = pluginsList.iterator();
|
if (pluginsList != null) {
|
||||||
while (it.hasNext()) {
|
Iterator<PluginBase> it = pluginsList.iterator();
|
||||||
PluginBase p = it.next();
|
while (it.hasNext()) {
|
||||||
if (p.getClass() == pluginClass)
|
PluginBase p = it.next();
|
||||||
return p;
|
if (p.getClass() == pluginClass)
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.debug("pluginsList=null");
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.NSProfileViewer;
|
package info.nightscout.androidaps.plugins.NSProfileViewer;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
@ -22,6 +23,7 @@ import java.text.DecimalFormat;
|
||||||
import info.nightscout.androidaps.Config;
|
import info.nightscout.androidaps.Config;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.Services.Intents;
|
||||||
import info.nightscout.androidaps.events.EventNewBasalProfile;
|
import info.nightscout.androidaps.events.EventNewBasalProfile;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||||
|
@ -119,7 +121,7 @@ public class NSProfileViewerFragment extends Fragment implements PluginBase, Pro
|
||||||
private void setContent() {
|
private void setContent() {
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
noProfile.setVisibility(View.VISIBLE);
|
noProfile.setVisibility(View.VISIBLE);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
noProfile.setVisibility(View.GONE);
|
noProfile.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
@ -187,6 +189,9 @@ public class NSProfileViewerFragment extends Fragment implements PluginBase, Pro
|
||||||
} else {
|
} else {
|
||||||
if (Config.logPrefsChange) {
|
if (Config.logPrefsChange) {
|
||||||
log.debug("Stored profile not found");
|
log.debug("Stored profile not found");
|
||||||
|
// force restart of nsclient to fetch profile
|
||||||
|
Intent restartNSClient = new Intent(Intents.ACTION_RESTART);
|
||||||
|
MainApp.instance().getApplicationContext().sendBroadcast(restartNSClient);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class NewTreatmentDialog extends DialogFragment implements OnClickListene
|
||||||
Double insulin = SafeParse.stringToDouble(this.insulin.getText().toString());
|
Double insulin = SafeParse.stringToDouble(this.insulin.getText().toString());
|
||||||
Integer carbs = SafeParse.stringToInt(this.carbs.getText().toString());
|
Integer carbs = SafeParse.stringToInt(this.carbs.getText().toString());
|
||||||
|
|
||||||
String confirmMessage = getString(R.string.entertreatmentquestion);
|
String confirmMessage = getString(R.string.entertreatmentquestion) + "\n";
|
||||||
|
|
||||||
Double insulinAfterConstraints = MainApp.getConfigBuilder().applyBolusConstraints(insulin);
|
Double insulinAfterConstraints = MainApp.getConfigBuilder().applyBolusConstraints(insulin);
|
||||||
Integer carbsAfterConstraints = MainApp.getConfigBuilder().applyCarbsConstraints(carbs);
|
Integer carbsAfterConstraints = MainApp.getConfigBuilder().applyCarbsConstraints(carbs);
|
||||||
|
|
|
@ -35,8 +35,10 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
|
||||||
TextView bg, bgInsulin, bgUnits;
|
TextView bg, bgInsulin, bgUnits;
|
||||||
CheckBox bgCheckbox;
|
CheckBox bgCheckbox;
|
||||||
TextView carbs, carbsInsulin;
|
TextView carbs, carbsInsulin;
|
||||||
TextView iob, iobInsulin;
|
TextView bolusIobInsulin;
|
||||||
CheckBox iobCheckbox;
|
TextView basalIobInsulin;
|
||||||
|
CheckBox bolusIobCheckbox;
|
||||||
|
CheckBox basalIobCheckbox;
|
||||||
TextView correctionInsulin;
|
TextView correctionInsulin;
|
||||||
TextView total, totalInsulin;
|
TextView total, totalInsulin;
|
||||||
|
|
||||||
|
@ -48,20 +50,22 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
|
||||||
|
|
||||||
final private TextWatcher textWatcher = new TextWatcher() {
|
final private TextWatcher textWatcher = new TextWatcher() {
|
||||||
@Override
|
@Override
|
||||||
public void afterTextChanged(Editable s) {}
|
public void afterTextChanged(Editable s) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTextChanged(CharSequence s, int start,int before, int count) {
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||||
calculateInsulin();
|
calculateInsulin();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
final CompoundButton.OnCheckedChangeListener onCheckedChangeListener = new CompoundButton.OnCheckedChangeListener()
|
final CompoundButton.OnCheckedChangeListener onCheckedChangeListener = new CompoundButton.OnCheckedChangeListener() {
|
||||||
{
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
{
|
|
||||||
calculateInsulin();
|
calculateInsulin();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -76,29 +80,31 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
|
||||||
|
|
||||||
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
|
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
|
||||||
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
|
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
|
||||||
correctionInput = (TextView)view.findViewById(R.id.treatments_wizard_correctioninput);
|
correctionInput = (TextView) view.findViewById(R.id.treatments_wizard_correctioninput);
|
||||||
carbsInput = (TextView)view.findViewById(R.id.treatments_wizard_carbsinput);
|
carbsInput = (TextView) view.findViewById(R.id.treatments_wizard_carbsinput);
|
||||||
bgInput = (TextView)view.findViewById(R.id.treatments_wizard_bginput);
|
bgInput = (TextView) view.findViewById(R.id.treatments_wizard_bginput);
|
||||||
|
|
||||||
correctionInput.addTextChangedListener(textWatcher);
|
correctionInput.addTextChangedListener(textWatcher);
|
||||||
carbsInput.addTextChangedListener(textWatcher);
|
carbsInput.addTextChangedListener(textWatcher);
|
||||||
bgInput.addTextChangedListener(textWatcher);
|
bgInput.addTextChangedListener(textWatcher);
|
||||||
|
|
||||||
bg = (TextView)view.findViewById(R.id.treatments_wizard_bg);
|
bg = (TextView) view.findViewById(R.id.treatments_wizard_bg);
|
||||||
bgInsulin = (TextView)view.findViewById(R.id.treatments_wizard_bginsulin);
|
bgInsulin = (TextView) view.findViewById(R.id.treatments_wizard_bginsulin);
|
||||||
bgUnits = (TextView)view.findViewById(R.id.treatments_wizard_bgunits);
|
bgUnits = (TextView) view.findViewById(R.id.treatments_wizard_bgunits);
|
||||||
bgCheckbox = (CheckBox) view.findViewById(R.id.treatments_wizard_bgcheckbox);
|
bgCheckbox = (CheckBox) view.findViewById(R.id.treatments_wizard_bgcheckbox);
|
||||||
carbs = (TextView)view.findViewById(R.id.treatments_wizard_carbs);
|
carbs = (TextView) view.findViewById(R.id.treatments_wizard_carbs);
|
||||||
carbsInsulin = (TextView)view.findViewById(R.id.treatments_wizard_carbsinsulin);
|
carbsInsulin = (TextView) view.findViewById(R.id.treatments_wizard_carbsinsulin);
|
||||||
iob = (TextView)view.findViewById(R.id.treatments_wizard_iob);
|
bolusIobInsulin = (TextView) view.findViewById(R.id.treatments_wizard_bolusiobinsulin);
|
||||||
iobInsulin = (TextView)view.findViewById(R.id.treatments_wizard_iobinsulin);
|
basalIobInsulin = (TextView) view.findViewById(R.id.treatments_wizard_basaliobinsulin);
|
||||||
iobCheckbox = (CheckBox) view.findViewById(R.id.treatments_wizard_iobcheckbox);
|
bolusIobCheckbox = (CheckBox) view.findViewById(R.id.treatments_wizard_bolusiobcheckbox);
|
||||||
correctionInsulin = (TextView)view.findViewById(R.id.treatments_wizard_correctioninsulin);
|
basalIobCheckbox = (CheckBox) view.findViewById(R.id.treatments_wizard_basaliobcheckbox);
|
||||||
total = (TextView)view.findViewById(R.id.treatments_wizard_total);
|
correctionInsulin = (TextView) view.findViewById(R.id.treatments_wizard_correctioninsulin);
|
||||||
totalInsulin = (TextView)view.findViewById(R.id.treatments_wizard_totalinsulin);
|
total = (TextView) view.findViewById(R.id.treatments_wizard_total);
|
||||||
|
totalInsulin = (TextView) view.findViewById(R.id.treatments_wizard_totalinsulin);
|
||||||
|
|
||||||
bgCheckbox.setOnCheckedChangeListener(onCheckedChangeListener);
|
bgCheckbox.setOnCheckedChangeListener(onCheckedChangeListener);
|
||||||
iobCheckbox.setOnCheckedChangeListener(onCheckedChangeListener);
|
basalIobCheckbox.setOnCheckedChangeListener(onCheckedChangeListener);
|
||||||
|
bolusIobCheckbox.setOnCheckedChangeListener(onCheckedChangeListener);
|
||||||
|
|
||||||
initDialog();
|
initDialog();
|
||||||
return view;
|
return view;
|
||||||
|
@ -108,7 +114,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
switch (view.getId()) {
|
switch (view.getId()) {
|
||||||
case R.id.treatments_wizard_deliverButton:
|
case R.id.treatments_wizard_deliverButton:
|
||||||
if (calculatedTotalInsulin > 0d || calculatedCarbs > 0d){
|
if (calculatedTotalInsulin > 0d || calculatedCarbs > 0d) {
|
||||||
DecimalFormat formatNumber2decimalplaces = new DecimalFormat("0.00");
|
DecimalFormat formatNumber2decimalplaces = new DecimalFormat("0.00");
|
||||||
String confirmMessage = getString(R.string.entertreatmentquestion);
|
String confirmMessage = getString(R.string.entertreatmentquestion);
|
||||||
|
|
||||||
|
@ -118,7 +124,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
|
||||||
confirmMessage += "\n" + getString(R.string.bolus) + ": " + formatNumber2decimalplaces.format(insulinAfterConstraints) + "U";
|
confirmMessage += "\n" + getString(R.string.bolus) + ": " + formatNumber2decimalplaces.format(insulinAfterConstraints) + "U";
|
||||||
confirmMessage += "\n" + getString(R.string.carbs) + ": " + carbsAfterConstraints + "g";
|
confirmMessage += "\n" + getString(R.string.carbs) + ": " + carbsAfterConstraints + "g";
|
||||||
|
|
||||||
if (insulinAfterConstraints != calculatedTotalInsulin || carbsAfterConstraints != calculatedCarbs) {
|
if (insulinAfterConstraints - calculatedTotalInsulin != 0 || carbsAfterConstraints != calculatedCarbs) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||||
builder.setTitle(getContext().getString(R.string.treatmentdeliveryerror));
|
builder.setTitle(getContext().getString(R.string.treatmentdeliveryerror));
|
||||||
builder.setMessage(getString(R.string.constraints_violation) + "\n" + getString(R.string.changeyourinput));
|
builder.setMessage(getString(R.string.constraints_violation) + "\n" + getString(R.string.changeyourinput));
|
||||||
|
@ -162,7 +168,6 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
|
||||||
|
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), "No profile loaded from NS yet");
|
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), "No profile loaded from NS yet");
|
||||||
dismiss();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,8 +180,8 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
|
||||||
if (lastBg != null) {
|
if (lastBg != null) {
|
||||||
Double lastBgValue = lastBg.valueToUnits(units);
|
Double lastBgValue = lastBg.valueToUnits(units);
|
||||||
Double sens = profile.getIsf(NSProfile.secondsFromMidnight());
|
Double sens = profile.getIsf(NSProfile.secondsFromMidnight());
|
||||||
Double targetBGLow = profile.getTargetLow(NSProfile.secondsFromMidnight());
|
Double targetBGLow = profile.getTargetLow(NSProfile.secondsFromMidnight());
|
||||||
Double targetBGHigh = profile.getTargetHigh(NSProfile.secondsFromMidnight());
|
Double targetBGHigh = profile.getTargetHigh(NSProfile.secondsFromMidnight());
|
||||||
Double bgDiff;
|
Double bgDiff;
|
||||||
if (lastBgValue <= targetBGLow) {
|
if (lastBgValue <= targetBGLow) {
|
||||||
bgDiff = lastBgValue - targetBGLow;
|
bgDiff = lastBgValue - targetBGLow;
|
||||||
|
@ -186,11 +191,15 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
|
||||||
|
|
||||||
bg.setText(lastBg.valueToUnitsToString(units) + " ISF: " + intFormat.format(sens));
|
bg.setText(lastBg.valueToUnitsToString(units) + " ISF: " + intFormat.format(sens));
|
||||||
bgInsulin.setText(numberFormat.format(bgDiff / sens) + "U");
|
bgInsulin.setText(numberFormat.format(bgDiff / sens) + "U");
|
||||||
|
bgInput.removeTextChangedListener(textWatcher);
|
||||||
bgInput.setText(lastBg.valueToUnitsToString(units));
|
bgInput.setText(lastBg.valueToUnitsToString(units));
|
||||||
|
bgInput.addTextChangedListener(textWatcher);
|
||||||
} else {
|
} else {
|
||||||
bg.setText("");
|
bg.setText("");
|
||||||
bgInsulin.setText("");
|
bgInsulin.setText("");
|
||||||
|
bgInput.removeTextChangedListener(textWatcher);
|
||||||
bgInput.setText("");
|
bgInput.setText("");
|
||||||
|
bgInput.addTextChangedListener(textWatcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
// IOB calculation
|
// IOB calculation
|
||||||
|
@ -201,8 +210,8 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
|
||||||
IobTotal bolusIob = treatments.getLastCalculation();
|
IobTotal bolusIob = treatments.getLastCalculation();
|
||||||
IobTotal basalIob = tempBasals.getLastCalculation();
|
IobTotal basalIob = tempBasals.getLastCalculation();
|
||||||
|
|
||||||
Double iobTotal = bolusIob.iob + basalIob.iob;
|
bolusIobInsulin.setText("-" + numberFormat.format(bolusIob.iob) + "U");
|
||||||
iobInsulin.setText("-" + numberFormat.format(iobTotal) + "U");
|
basalIobInsulin.setText("-" + numberFormat.format(basalIob.basaliob) + "U");
|
||||||
|
|
||||||
totalInsulin.setText("");
|
totalInsulin.setText("");
|
||||||
wizardDialogDeliverButton.setVisibility(Button.GONE);
|
wizardDialogDeliverButton.setVisibility(Button.GONE);
|
||||||
|
@ -216,29 +225,37 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
|
||||||
Double c_bg = SafeParse.stringToDouble(this.bgInput.getText().toString());
|
Double c_bg = SafeParse.stringToDouble(this.bgInput.getText().toString());
|
||||||
Integer c_carbs = SafeParse.stringToInt(this.carbsInput.getText().toString());
|
Integer c_carbs = SafeParse.stringToInt(this.carbsInput.getText().toString());
|
||||||
Double c_correction = SafeParse.stringToDouble(this.correctionInput.getText().toString());
|
Double c_correction = SafeParse.stringToDouble(this.correctionInput.getText().toString());
|
||||||
if(c_correction != MainApp.getConfigBuilder().applyBolusConstraints(c_correction)) {
|
Double corrAfterConstraint = MainApp.getConfigBuilder().applyBolusConstraints(c_correction);
|
||||||
this.correctionInput.setText("");
|
if (c_correction - corrAfterConstraint != 0) { // c_correction != corrAfterConstraint doesn't work
|
||||||
wizardDialogDeliverButton.setVisibility(Button.GONE);
|
correctionInput.removeTextChangedListener(textWatcher);
|
||||||
|
correctionInput.setText("");
|
||||||
|
correctionInput.addTextChangedListener(textWatcher);
|
||||||
|
//wizardDialogDeliverButton.setVisibility(Button.GONE);
|
||||||
|
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), getString(R.string.bolusconstraintapplied));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(c_carbs != MainApp.getConfigBuilder().applyCarbsConstraints(c_carbs)) {
|
Integer carbsAfterConstraint = MainApp.getConfigBuilder().applyCarbsConstraints(c_carbs);
|
||||||
this.carbsInput.setText("");
|
if (c_carbs != carbsAfterConstraint) {
|
||||||
wizardDialogDeliverButton.setVisibility(Button.GONE);
|
carbsInput.removeTextChangedListener(textWatcher);
|
||||||
|
carbsInput.setText("");
|
||||||
|
carbsInput.addTextChangedListener(textWatcher);
|
||||||
|
//wizardDialogDeliverButton.setVisibility(Button.GONE);
|
||||||
|
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), getString(R.string.carbsconstraintapplied));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Insulin from BG
|
// Insulin from BG
|
||||||
Double sens = profile.getIsf(NSProfile.secondsFromMidnight());
|
Double sens = profile.getIsf(NSProfile.secondsFromMidnight());
|
||||||
Double targetBGLow = profile.getTargetLow(NSProfile.secondsFromMidnight());
|
Double targetBGLow = profile.getTargetLow(NSProfile.secondsFromMidnight());
|
||||||
Double targetBGHigh = profile.getTargetHigh(NSProfile.secondsFromMidnight());
|
Double targetBGHigh = profile.getTargetHigh(NSProfile.secondsFromMidnight());
|
||||||
Double bgDiff;
|
Double bgDiff;
|
||||||
if (c_bg <= targetBGLow) {
|
if (c_bg <= targetBGLow) {
|
||||||
bgDiff = c_bg - targetBGLow;
|
bgDiff = c_bg - targetBGLow;
|
||||||
} else {
|
} else {
|
||||||
bgDiff = c_bg - targetBGHigh;
|
bgDiff = c_bg - targetBGHigh;
|
||||||
}
|
}
|
||||||
Double insulinFromBG = (bgCheckbox.isChecked() && c_bg != 0d) ? bgDiff /sens : 0d;
|
Double insulinFromBG = (bgCheckbox.isChecked() && c_bg != 0d) ? bgDiff / sens : 0d;
|
||||||
bg.setText(c_bg + " ISF: " + intFormat.format(sens));
|
bg.setText(c_bg + " ISF: " + intFormat.format(sens));
|
||||||
bgInsulin.setText(numberFormat.format(insulinFromBG) + "U");
|
bgInsulin.setText(numberFormat.format(insulinFromBG) + "U");
|
||||||
|
|
||||||
|
@ -256,16 +273,17 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
|
||||||
IobTotal bolusIob = treatments.getLastCalculation();
|
IobTotal bolusIob = treatments.getLastCalculation();
|
||||||
IobTotal basalIob = tempBasals.getLastCalculation();
|
IobTotal basalIob = tempBasals.getLastCalculation();
|
||||||
|
|
||||||
Double iobTotal = bolusIob.iob + basalIob.iob;
|
Double insulingFromBolusIOB = bolusIobCheckbox.isChecked() ? -bolusIob.iob : 0d;
|
||||||
Double insulingFromIOB = iobCheckbox.isChecked() ? iobTotal : 0d;
|
Double insulingFromBasalsIOB = basalIobCheckbox.isChecked() ? -basalIob.basaliob : 0d;
|
||||||
iobInsulin.setText("-" + numberFormat.format(insulingFromIOB) + "U");
|
bolusIobInsulin.setText(numberFormat.format(insulingFromBolusIOB) + "U");
|
||||||
|
basalIobInsulin.setText(numberFormat.format(insulingFromBasalsIOB) + "U");
|
||||||
|
|
||||||
// Insulin from correction
|
// Insulin from correction
|
||||||
Double insulinFromCorrection = c_correction;
|
Double insulinFromCorrection = corrAfterConstraint;
|
||||||
correctionInsulin.setText(numberFormat.format(insulinFromCorrection) + "U");
|
correctionInsulin.setText(numberFormat.format(insulinFromCorrection) + "U");
|
||||||
|
|
||||||
// Total
|
// Total
|
||||||
calculatedTotalInsulin = insulinFromBG + insulinFromCarbs - insulingFromIOB + insulinFromCorrection;
|
calculatedTotalInsulin = insulinFromBG + insulinFromCarbs + insulingFromBolusIOB + insulingFromBasalsIOB + insulinFromCorrection;
|
||||||
|
|
||||||
if (calculatedTotalInsulin < 0) {
|
if (calculatedTotalInsulin < 0) {
|
||||||
Double carbsEquivalent = -calculatedTotalInsulin * ic;
|
Double carbsEquivalent = -calculatedTotalInsulin * ic;
|
||||||
|
|
|
@ -377,11 +377,6 @@ public class OverviewFragment extends Fragment implements PluginBase {
|
||||||
BgReading lastBG = MainApp.getDbHelper().lastBg();
|
BgReading lastBG = MainApp.getDbHelper().lastBg();
|
||||||
if (MainApp.getConfigBuilder() == null || MainApp.getConfigBuilder().getActiveProfile() == null) // app not initialized yet
|
if (MainApp.getConfigBuilder() == null || MainApp.getConfigBuilder().getActiveProfile() == null) // app not initialized yet
|
||||||
return;
|
return;
|
||||||
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
|
||||||
if (profile == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
String units = profile.getUnits();
|
|
||||||
|
|
||||||
// Skip if not initialized yet
|
// Skip if not initialized yet
|
||||||
if (bgGraph == null)
|
if (bgGraph == null)
|
||||||
|
@ -412,6 +407,7 @@ public class OverviewFragment extends Fragment implements PluginBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// **** Temp button ****
|
// **** Temp button ****
|
||||||
|
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
||||||
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||||
|
|
||||||
if (pump.isTempBasalInProgress()) {
|
if (pump.isTempBasalInProgress()) {
|
||||||
|
@ -427,6 +423,22 @@ public class OverviewFragment extends Fragment implements PluginBase {
|
||||||
runningTempView.setText(formatNumber2decimalplaces.format(currentBasal) + " U/h");
|
runningTempView.setText(formatNumber2decimalplaces.format(currentBasal) + " U/h");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (profile == null) {
|
||||||
|
// disable all treatment buttons because we are not able to check constraints without profile
|
||||||
|
setExtenedButton.setVisibility(View.INVISIBLE);
|
||||||
|
setTempLayout.setVisibility(View.INVISIBLE);
|
||||||
|
wizardButton.setVisibility(View.INVISIBLE);
|
||||||
|
treatmentButton.setVisibility(View.INVISIBLE);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
setExtenedButton.setVisibility(View.VISIBLE);
|
||||||
|
setTempLayout.setVisibility(View.VISIBLE);
|
||||||
|
wizardButton.setVisibility(View.VISIBLE);
|
||||||
|
treatmentButton.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
String units = profile.getUnits();
|
||||||
|
|
||||||
// **** BG value ****
|
// **** BG value ****
|
||||||
if (profile != null && lastBG != null && bgView != null) {
|
if (profile != null && lastBG != null && bgView != null) {
|
||||||
bgView.setText(lastBG.valueToUnitsToString(profile.getUnits()));
|
bgView.setText(lastBG.valueToUnitsToString(profile.getUnits()));
|
||||||
|
|
|
@ -204,28 +204,64 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:width="32dp"
|
android:width="32dp"
|
||||||
android:id="@+id/treatments_wizard_iobcheckbox"
|
android:id="@+id/treatments_wizard_bolusiobcheckbox"
|
||||||
android:checked="true" />
|
android:checked="true" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
android:text="@string/treatments_wizard_iob_label"
|
android:text="@string/treatments_wizard_bolusiob_label"
|
||||||
android:width="50dp" />
|
android:width="100dp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
android:width="100dp"
|
android:width="50dp"
|
||||||
android:id="@+id/treatments_wizard_iob" />
|
android:id="@+id/treatments_wizard_bolusiob" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
android:id="@+id/treatments_wizard_iobinsulin"
|
android:id="@+id/treatments_wizard_bolusiobinsulin"
|
||||||
|
android:width="50dp"
|
||||||
|
android:gravity="end" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center">
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:width="32dp"
|
||||||
|
android:id="@+id/treatments_wizard_basaliobcheckbox"
|
||||||
|
android:checked="true" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
|
android:text="@string/treatments_wizard_basaliob_label"
|
||||||
|
android:width="100dp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
|
android:width="50dp"
|
||||||
|
android:id="@+id/treatments_wizard_basaliob" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
|
android:id="@+id/treatments_wizard_basaliobinsulin"
|
||||||
android:width="50dp"
|
android:width="50dp"
|
||||||
android:gravity="end" />
|
android:gravity="end" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
<string name="treatments_wizard_carbs_label">Carbs</string>
|
<string name="treatments_wizard_carbs_label">Carbs</string>
|
||||||
<string name="treatments_wizard_correction_label">Corr</string>
|
<string name="treatments_wizard_correction_label">Corr</string>
|
||||||
<string name="treatments_wizard_unit_label">U</string>
|
<string name="treatments_wizard_unit_label">U</string>
|
||||||
<string name="treatments_wizard_iob_label">IOB</string>
|
<string name="treatments_wizard_bolusiob_label">Bolus IOB</string>
|
||||||
<string name="treatments_wizard_total_label">TOTAL</string>
|
<string name="treatments_wizard_total_label">TOTAL</string>
|
||||||
<string name="openapsma_run">Run now</string>
|
<string name="openapsma_run">Run now</string>
|
||||||
<string name="vitualpump_label">VIRTUAL PUMP</string>
|
<string name="vitualpump_label">VIRTUAL PUMP</string>
|
||||||
|
@ -156,5 +156,8 @@
|
||||||
<string name="loopdisabled">LOOP DISABLED BY CONSTRAINTS</string>
|
<string name="loopdisabled">LOOP DISABLED BY CONSTRAINTS</string>
|
||||||
<string name="cs_lang">Czech language</string>
|
<string name="cs_lang">Czech language</string>
|
||||||
<string name="en_lang">English language</string>
|
<string name="en_lang">English language</string>
|
||||||
|
<string name="treatments_wizard_basaliob_label">Basal IOB</string>
|
||||||
|
<string name="bolusconstraintapplied">Bolus constraint applied</string>
|
||||||
|
<string name="carbsconstraintapplied">Carbs constraint applied</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue