extended bolus dialog

This commit is contained in:
Milos Kozak 2017-05-30 15:07:44 +02:00
parent 5f6a77983b
commit 3861bece54
14 changed files with 127 additions and 129 deletions

View file

@ -15,6 +15,8 @@ public class PumpDescription {
public boolean isExtendedBolusCapable = true;
public double extendedBolusStep = 0.1d;
public double extendedBolusDurationStep = 30;
public double extendedBolusMaxDuration = 12 * 60;
public boolean isTempBasalCapable = true;
public int lowTempBasalStyle = PERCENT;

View file

@ -29,15 +29,8 @@ import info.nightscout.utils.SafeParse;
public class NewExtendedBolusDialog extends DialogFragment implements View.OnClickListener {
Button okButton;
EditText insulinEdit;
RadioButton h05Radio;
RadioButton h10Radio;
RadioButton h20Radio;
RadioButton h30Radio;
RadioButton h40Radio;
PlusMinusEditText editInsulin;
PlusMinusEditText editDuration;
Handler mHandler;
public static HandlerThread mHandlerThread;
@ -54,18 +47,16 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli
getDialog().setTitle(getString(R.string.overview_extendedbolus_button));
View view = inflater.inflate(R.layout.overview_newextendedbolus_dialog, container, false);
okButton = (Button) view.findViewById(R.id.overview_newextendedbolus_okbutton);
insulinEdit = (EditText) view.findViewById(R.id.overview_newextendedbolus_insulin);
h05Radio = (RadioButton) view.findViewById(R.id.overview_newextendedbolus_05h);
h10Radio = (RadioButton) view.findViewById(R.id.overview_newextendedbolus_1h);
h20Radio = (RadioButton) view.findViewById(R.id.overview_newextendedbolus_2h);
h30Radio = (RadioButton) view.findViewById(R.id.overview_newextendedbolus_3h);
h40Radio = (RadioButton) view.findViewById(R.id.overview_newextendedbolus_4h);
Double maxInsulin = MainApp.getConfigBuilder().applyBolusConstraints(Constants.bolusOnlyForCheckLimit);
editInsulin = new PlusMinusEditText(view, R.id.overview_newextendedbolus_insulin, R.id.overview_newextendedbolus_insulin_plus, R.id.overview_newextendedbolus_insulin_minus, 0d, 0d, maxInsulin, 0.1d, new DecimalFormat("0.00"), false);
okButton.setOnClickListener(this);
double extendedDurationStep = MainApp.getConfigBuilder().getPumpDescription().extendedBolusDurationStep;
double extendedMaxDuration = MainApp.getConfigBuilder().getPumpDescription().extendedBolusMaxDuration;
editDuration = new PlusMinusEditText(view, R.id.overview_newextendedbolus_duration, R.id.overview_newextendedbolus_duration_plus, R.id.overview_newextendedbolus_duration_minus, extendedDurationStep, extendedDurationStep, extendedMaxDuration, extendedDurationStep, new DecimalFormat("0"), false);
view.findViewById(R.id.ok).setOnClickListener(this);
view.findViewById(R.id.cancel).setOnClickListener(this);
return view;
}
@ -79,14 +70,10 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.overview_newextendedbolus_okbutton:
case R.id.ok:
try {
Double insulin = SafeParse.stringToDouble(insulinEdit.getText().toString());
int durationInMinutes = 30;
if (h10Radio.isChecked()) durationInMinutes = 60;
if (h20Radio.isChecked()) durationInMinutes = 120;
if (h30Radio.isChecked()) durationInMinutes = 180;
if (h40Radio.isChecked()) durationInMinutes = 240;
Double insulin = SafeParse.stringToDouble(editInsulin.getText());
int durationInMinutes = SafeParse.stringToInt(editDuration.getText());
String confirmMessage = getString(R.string.setextendedbolusquestion);
@ -130,6 +117,10 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli
} catch (Exception e) {
e.printStackTrace();
}
break;
case R.id.cancel:
dismiss();
break;
}
}

View file

@ -33,11 +33,6 @@ import info.nightscout.utils.SafeParse;
public class NewTreatmentDialog extends DialogFragment implements OnClickListener {
Button okButton;
Button cancelButton;
TextView insulin;
TextView carbs;
PlusMinusEditText editCarbs;
PlusMinusEditText editInsulin;
@ -55,15 +50,11 @@ public class NewTreatmentDialog extends DialogFragment implements OnClickListene
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.overview_newtreatment_dialog, null, false);
okButton = (Button) view.findViewById(R.id.ok);
okButton.setOnClickListener(this);
cancelButton = (Button) view.findViewById(R.id.cancel);
cancelButton.setOnClickListener(this);
view.findViewById(R.id.ok).setOnClickListener(this);
view.findViewById(R.id.cancel).setOnClickListener(this);
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
insulin = (TextView) view.findViewById(R.id.treatments_newtreatment_insulinamount);
carbs = (TextView) view.findViewById(R.id.treatments_newtreatment_carbsamount);
Integer maxCarbs = MainApp.getConfigBuilder().applyCarbsConstraints(Constants.carbsOnlyForCheckLimit);
Double maxInsulin = MainApp.getConfigBuilder().applyBolusConstraints(Constants.bolusOnlyForCheckLimit);
@ -87,8 +78,8 @@ public class NewTreatmentDialog extends DialogFragment implements OnClickListene
case R.id.ok:
try {
Double insulin = SafeParse.stringToDouble(this.insulin.getText().toString());
final Integer carbs = SafeParse.stringToInt(this.carbs.getText().toString());
Double insulin = SafeParse.stringToDouble(editInsulin.getText());
final Integer carbs = SafeParse.stringToInt(editCarbs.getText());
String confirmMessage = getString(R.string.entertreatmentquestion) + "\n";

View file

@ -83,6 +83,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
pumpDescription.isExtendedBolusCapable = true;
pumpDescription.extendedBolusStep = 0.05d;
pumpDescription.extendedBolusDurationStep = 30;
pumpDescription.isTempBasalCapable = true;
pumpDescription.lowTempBasalStyle = PumpDescription.PERCENT;

View file

@ -96,7 +96,7 @@ public class DanaRExecutionService extends Service {
private PowerManager.WakeLock mWakeLock;
private IBinder mBinder = new LocalBinder();
private DanaRPump danaRPump;
private DanaRPump danaRPump = DanaRPump.getInstance();
private Treatment bolusingTreatment = null;
private static Boolean connectionInProgress = false;
@ -124,7 +124,6 @@ public class DanaRExecutionService extends Service {
public DanaRExecutionService() {
registerBus();
MainApp.instance().getApplicationContext().registerReceiver(receiver, new IntentFilter(BluetoothDevice.ACTION_ACL_DISCONNECTED));
danaRPump = DanaRPump.getInstance();
PowerManager powerManager = (PowerManager) MainApp.instance().getApplicationContext().getSystemService(Context.POWER_SERVICE);
mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "DanaRExecutionService");
@ -404,6 +403,7 @@ public class DanaRExecutionService extends Service {
Calendar time = Calendar.getInstance();
mSerialIOThread.sendMessage(new MsgSetCarbsEntry(time, carbs));
}
MsgBolusProgress progress = new MsgBolusProgress(amount, t); // initialize static variables
MainApp.bus().post(new EventDanaRBolusStart());
long startTime = new Date().getTime();

View file

@ -86,6 +86,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
pumpDescription.isExtendedBolusCapable = true;
pumpDescription.extendedBolusStep = 0.05d;
pumpDescription.extendedBolusDurationStep = 30;
pumpDescription.isTempBasalCapable = true;
pumpDescription.lowTempBasalStyle = PumpDescription.PERCENT;

View file

@ -219,7 +219,7 @@ public class DanaRKoreanExecutionService extends Service {
mSerialIOThread.disconnect("Recreate SerialIOThread");
}
mSerialIOThread = new SerialIOThread(mRfcommSocket);
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTED));
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTED, 0));
if (!getPumpStatus()) {
mSerialIOThread.disconnect("getPumpStatus failed");
waitMsec(3000);
@ -385,7 +385,7 @@ public class DanaRKoreanExecutionService extends Service {
return true;
}
public boolean bolus(Double amount, int carbs, Treatment t) {
public boolean bolus(double amount, int carbs, Treatment t) {
bolusingTreatment = t;
MsgBolusStart start = new MsgBolusStart(amount);
MsgBolusStop stop = new MsgBolusStop(amount, t);

View file

@ -83,6 +83,7 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, ConstraintsInte
pumpDescription.isExtendedBolusCapable = true;
pumpDescription.extendedBolusStep = 0.05d;
pumpDescription.extendedBolusDurationStep = 30;
pumpDescription.isTempBasalCapable = true;
pumpDescription.lowTempBasalStyle = PumpDescription.PERCENT;

View file

@ -371,7 +371,7 @@ public class DanaRv2ExecutionService extends Service {
return true;
}
public boolean bolus(Double amount, int carbs, Treatment t) {
public boolean bolus(double amount, int carbs, Treatment t) {
bolusingTreatment = t;
MsgBolusStart start = new MsgBolusStart(amount);
MsgBolusStop stop = new MsgBolusStop(amount, t);

View file

@ -39,26 +39,8 @@ public class MDIPlugin implements PluginBase, PumpInterface {
pumpDescription.bolusStep = 0.5d;
pumpDescription.isExtendedBolusCapable = false;
pumpDescription.extendedBolusStep = 0d;
pumpDescription.isTempBasalCapable = false;
pumpDescription.lowTempBasalStyle = PumpDescription.NONE;
pumpDescription.highTempBasalStyle = PumpDescription.NONE;
pumpDescription.maxHighTempPercent = 0;
pumpDescription.maxHighTempAbsolute = 0;
pumpDescription.lowTempPercentStep = 0;
pumpDescription.lowTempAbsoluteStep = 0;
pumpDescription.lowTempPercentDuration = 0;
pumpDescription.lowTempAbsoluteDuration = 0;
pumpDescription.highTempPercentStep = 0;
pumpDescription.highTempAbsoluteStep = 0d;
pumpDescription.highTempPercentDuration = 0;
pumpDescription.highTempAbsoluteDuration = 0;
pumpDescription.isSetBasalProfileCapable = false;
pumpDescription.basalStep = 0d;
pumpDescription.basalMinimumRate = 0d;
pumpDescription.isRefillingCapable = false;
}

View file

@ -55,6 +55,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
pumpDescription.isExtendedBolusCapable = true;
pumpDescription.extendedBolusStep = 0.2d;
pumpDescription.extendedBolusDurationStep = 30;
pumpDescription.isTempBasalCapable = true;
pumpDescription.lowTempBasalStyle = PumpDescription.ABSOLUTE | PumpDescription.PERCENT;
@ -72,7 +73,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
pumpDescription.isSetBasalProfileCapable = true;
pumpDescription.basalStep = 0.01d;
pumpDescription.basalMinimumRate = 0.04d;
pumpDescription.basalMinimumRate = 0.01d;
pumpDescription.isRefillingCapable = false;
}

View file

@ -116,6 +116,10 @@ public class PlusMinusEditText implements View.OnKeyListener,
return value;
}
public String getText() {
return editText.getText().toString();
}
public void setStep(Double step) {
this.step = step;
}

View file

@ -9,29 +9,31 @@
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp">
<LinearLayout
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:padding="10dp"
android:layout_alignParentStart="true"
android:text="@string/treatments_newtreatment_insulinamount_label"
android:textAppearance="?android:attr/textAppearanceLarge" />
android:textAppearance="@android:style/TextAppearance.Material.Small"
android:textStyle="bold" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:orientation="horizontal">
<ImageView
@ -49,12 +51,12 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:inputType="numberDecimal"
android:minWidth="100dp"
android:padding="10dp"
android:text=""
android:textAppearance="?android:attr/textAppearanceLarge"
android:gravity="center_horizontal" />
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="@+id/overview_newextendedbolus_insulin_plus"
@ -67,55 +69,77 @@
android:tint="#ffffff" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_alignParentBottom="true"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:background="@color/listdelimiter" />
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal">
</RelativeLayout>
<RadioButton
android:id="@+id/overview_newextendedbolus_05h"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="0.5 h" />
<RadioButton
android:id="@+id/overview_newextendedbolus_1h"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1 h" />
<RadioButton
android:id="@+id/overview_newextendedbolus_2h"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2 h" />
<RadioButton
android:id="@+id/overview_newextendedbolus_3h"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="3 h" />
<RadioButton
android:id="@+id/overview_newextendedbolus_4h"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="4 h" />
</RadioGroup>
<Button
android:id="@+id/overview_newextendedbolus_okbutton"
style="?android:attr/buttonStyle"
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="OK"
android:textSize="20sp" />
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_marginTop="5dp"
android:text="@string/careportal_newnstreatment_duration_label"
android:textAppearance="@android:style/TextAppearance.Material.Small"
android:textStyle="bold" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/overview_newextendedbolus_duration_minus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/circle"
android:backgroundTint="#ffffff"
android:src="@drawable/ic_action_minus"
android:tint="#ffffff" />
<EditText
android:id="@+id/overview_newextendedbolus_duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:inputType="numberDecimal"
android:minWidth="100dp"
android:padding="10dp"
android:text=""
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="@+id/overview_newextendedbolus_duration_plus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/circle"
android:backgroundTint="#ffffff"
android:src="@drawable/ic_action_add"
android:tint="#ffffff" />
</LinearLayout>
</RelativeLayout>
<include layout="@layout/mdtp_done_button" />
</LinearLayout>
</ScrollView>
</FrameLayout>

View file

@ -64,8 +64,8 @@
android:id="@+id/overview_newtempbasal_percent_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center_horizontal">
android:layout_gravity="center_horizontal"
android:orientation="horizontal">
<ImageView
@ -73,11 +73,11 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.5"
android:background="@drawable/circle"
android:backgroundTint="#ffffff"
android:src="@drawable/ic_action_minus"
android:tint="#ffffff"
android:layout_weight="0.5" />
android:tint="#ffffff" />
<EditText
android:id="@+id/overview_newtempbasal_basalpercentinput"
@ -85,23 +85,23 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="0.5"
android:gravity="center_horizontal"
android:inputType="numberDecimal"
android:minWidth="100dp"
android:padding="10dp"
android:text=""
android:textAppearance="?android:attr/textAppearanceLarge"
android:gravity="center_horizontal" />
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="@+id/overview_newtempbasal_basalpercent_plus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.5"
android:background="@drawable/circle"
android:backgroundTint="#ffffff"
android:src="@drawable/ic_action_add"
android:tint="#ffffff"
android:layout_weight="0.5" />
android:tint="#ffffff" />
</LinearLayout>
@ -110,8 +110,8 @@
android:id="@+id/overview_newtempbasal_absolute_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center_horizontal">
android:layout_gravity="center_horizontal"
android:orientation="horizontal">
<ImageView
@ -119,11 +119,11 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.5"
android:background="@drawable/circle"
android:backgroundTint="#ffffff"
android:src="@drawable/ic_action_minus"
android:tint="#ffffff"
android:layout_weight="0.5" />
android:tint="#ffffff" />
<EditText
android:id="@+id/overview_newtempbasal_basalabsoluteinput"
@ -131,23 +131,23 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="0.5"
android:gravity="center_horizontal"
android:inputType="numberDecimal"
android:minWidth="100dp"
android:padding="10dp"
android:text=""
android:textAppearance="?android:attr/textAppearanceLarge"
android:gravity="center_horizontal" />
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="@+id/overview_newtempbasal_basalabsolute_plus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.5"
android:background="@drawable/circle"
android:backgroundTint="#ffffff"
android:src="@drawable/ic_action_add"
android:tint="#ffffff"
android:layout_weight="0.5" />
android:tint="#ffffff" />
</LinearLayout>