combobolus dialog plus/minus buttons

This commit is contained in:
Milos Kozak 2016-07-03 13:46:49 +02:00
parent 07b01cd8d0
commit 2b01b2a10b
2 changed files with 59 additions and 21 deletions

View file

@ -11,10 +11,14 @@ import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.RadioButton; import android.widget.RadioButton;
import java.text.DecimalFormat;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.utils.PlusMinusEditText;
import info.nightscout.utils.SafeParse; import info.nightscout.utils.SafeParse;
public class NewExtendedBolusDialog extends DialogFragment implements View.OnClickListener { public class NewExtendedBolusDialog extends DialogFragment implements View.OnClickListener {
@ -27,6 +31,8 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli
RadioButton h30Radio; RadioButton h30Radio;
RadioButton h40Radio; RadioButton h40Radio;
PlusMinusEditText editInsulin;
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
@ -41,6 +47,9 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli
h30Radio = (RadioButton) view.findViewById(R.id.overview_newextendedbolus_3h); h30Radio = (RadioButton) view.findViewById(R.id.overview_newextendedbolus_3h);
h40Radio = (RadioButton) view.findViewById(R.id.overview_newextendedbolus_4h); 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.05d, new DecimalFormat("0.00"), false);
okButton.setOnClickListener(this); okButton.setOnClickListener(this);
return view; return view;
} }

View file

@ -18,16 +18,45 @@
android:text="@string/treatments_newtreatment_insulinamount_label" android:text="@string/treatments_newtreatment_insulinamount_label"
android:textAppearance="?android:attr/textAppearanceLarge" /> android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText <LinearLayout
android:id="@+id/overview_newextendedbolus_insulin"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:inputType="numberDecimal" android:orientation="horizontal">
android:minWidth="200dp"
android:padding="10dp" <ImageView
android:text="" android:id="@+id/overview_newextendedbolus_insulin_plus"
android:textAppearance="?android:attr/textAppearanceLarge" /> 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" />
<EditText
android:id="@+id/overview_newextendedbolus_insulin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:inputType="numberDecimal"
android:minWidth="200dp"
android:padding="10dp"
android:text=""
android:textAppearance="?android:attr/textAppearanceLarge"
android:gravity="center_horizontal" />
<ImageView
android:id="@+id/overview_newextendedbolus_insulin_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" />
</LinearLayout>
</LinearLayout> </LinearLayout>
<RadioGroup <RadioGroup
@ -36,35 +65,35 @@
android:layout_gravity="center_horizontal"> android:layout_gravity="center_horizontal">
<RadioButton <RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0.5 h"
android:id="@+id/overview_newextendedbolus_05h" android:id="@+id/overview_newextendedbolus_05h"
android:checked="true" />
<RadioButton
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="1 h" android:checked="true"
android:id="@+id/overview_newextendedbolus_1h" /> android:text="0.5 h" />
<RadioButton <RadioButton
android:id="@+id/overview_newextendedbolus_1h"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="2 h" android:text="1 h" />
android:id="@+id/overview_newextendedbolus_2h" />
<RadioButton <RadioButton
android:id="@+id/overview_newextendedbolus_2h"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="3 h" android:text="2 h" />
android:id="@+id/overview_newextendedbolus_3h" />
<RadioButton <RadioButton
android:id="@+id/overview_newextendedbolus_3h"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="4 h" android:text="3 h" />
android:id="@+id/overview_newextendedbolus_4h" />
<RadioButton
android:id="@+id/overview_newextendedbolus_4h"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="4 h" />
</RadioGroup> </RadioGroup>
<Button <Button