temp basal dialog plus/minus buttons
This commit is contained in:
parent
000fafced3
commit
5cad7f1cb4
9 changed files with 195 additions and 57 deletions
|
@ -23,8 +23,8 @@ android {
|
|||
applicationId "info.nightscout.androidaps"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 23
|
||||
versionCode 1002
|
||||
versionName "1.0.02"
|
||||
versionCode 1003
|
||||
versionName "1.0.03"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
|
|
|
@ -30,6 +30,8 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli
|
|||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
getDialog().setTitle(getString(R.string.overview_extendedbolus_button));
|
||||
|
||||
View view = inflater.inflate(R.layout.overview_newextendedbolus_fragment, container, false);
|
||||
okButton = (Button) view.findViewById(R.id.overview_newextendedbolus_okbutton);
|
||||
insulinEdit = (EditText) view.findViewById(R.id.overview_newextendedbolus_insulin);
|
||||
|
|
|
@ -9,41 +9,73 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.RadioGroup;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.client.data.NSProfile;
|
||||
import info.nightscout.utils.PlusMinusEditText;
|
||||
import info.nightscout.utils.SafeParse;
|
||||
|
||||
public class NewTempBasalDialog extends DialogFragment implements View.OnClickListener {
|
||||
public class NewTempBasalDialog extends DialogFragment implements View.OnClickListener, RadioGroup.OnCheckedChangeListener {
|
||||
|
||||
Button okButton;
|
||||
EditText basalEdit;
|
||||
EditText basalPercentEdit;
|
||||
EditText basalAbsoluteEdit;
|
||||
RadioButton percentRadio;
|
||||
RadioButton absoluteRadio;
|
||||
RadioGroup basalTypeRadioGroup;
|
||||
RadioButton h05Radio;
|
||||
RadioButton h10Radio;
|
||||
RadioButton h20Radio;
|
||||
RadioButton h30Radio;
|
||||
RadioButton h40Radio;
|
||||
|
||||
LinearLayout percentLayout;
|
||||
LinearLayout absoluteLayout;
|
||||
|
||||
PlusMinusEditText basalPercentPM;
|
||||
PlusMinusEditText basalAbsolutePM;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
getDialog().setTitle(getString(R.string.overview_tempbasal_button));
|
||||
|
||||
View view = inflater.inflate(R.layout.overview_newtempbasal_fragment, container, false);
|
||||
okButton = (Button) view.findViewById(R.id.overview_newtempbasal_okbutton);
|
||||
basalEdit = (EditText) view.findViewById(R.id.overview_newtempbasal_basal);
|
||||
percentRadio = (RadioButton) view.findViewById(R.id.overview_newtempbasal_percent);
|
||||
absoluteRadio = (RadioButton) view.findViewById(R.id.overview_newtempbasal_absolute);
|
||||
basalPercentEdit = (EditText) view.findViewById(R.id.overview_newtempbasal_basalpercentinput);
|
||||
basalAbsoluteEdit = (EditText) view.findViewById(R.id.overview_newtempbasal_basalabsoluteinput);
|
||||
percentLayout = (LinearLayout) view.findViewById(R.id.overview_newtempbasal_percent_layout);
|
||||
absoluteLayout = (LinearLayout) view.findViewById(R.id.overview_newtempbasal_absolute_layout);
|
||||
percentRadio = (RadioButton) view.findViewById(R.id.overview_newtempbasal_percent_radio);
|
||||
basalTypeRadioGroup = (RadioGroup) view.findViewById(R.id.overview_newtempbasal_radiogroup);
|
||||
absoluteRadio = (RadioButton) view.findViewById(R.id.overview_newtempbasal_absolute_radio);
|
||||
h05Radio = (RadioButton) view.findViewById(R.id.overview_newtempbasal_05h);
|
||||
h10Radio = (RadioButton) view.findViewById(R.id.overview_newtempbasal_1h);
|
||||
h20Radio = (RadioButton) view.findViewById(R.id.overview_newtempbasal_2h);
|
||||
h30Radio = (RadioButton) view.findViewById(R.id.overview_newtempbasal_3h);
|
||||
h40Radio = (RadioButton) view.findViewById(R.id.overview_newtempbasal_4h);
|
||||
|
||||
Integer maxPercent = MainApp.getConfigBuilder().applyBasalConstraints(Constants.basalPercentOnlyForCheckLimit);
|
||||
basalPercentPM = new PlusMinusEditText(view, R.id.overview_newtempbasal_basalpercentinput, R.id.overview_newtempbasal_basalpercent_plus, R.id.overview_newtempbasal_basalpercent_minus, 100d, 0d, (double) maxPercent, 5d, new DecimalFormat("0"), true);
|
||||
|
||||
Double maxAbsolute = MainApp.getConfigBuilder().applyBasalConstraints(Constants.basalAbsoluteOnlyForCheckLimit);
|
||||
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
||||
Double currentBasal = 0d;
|
||||
if (profile != null) currentBasal = profile.getBasal(NSProfile.secondsFromMidnight());
|
||||
basalAbsolutePM = new PlusMinusEditText(view, R.id.overview_newtempbasal_basalabsoluteinput, R.id.overview_newtempbasal_basalabsolute_plus, R.id.overview_newtempbasal_basalabsolute_minus, currentBasal, 0d, maxAbsolute, 0.05d, new DecimalFormat("0.00"), true);
|
||||
|
||||
absoluteLayout.setVisibility(View.GONE);
|
||||
okButton.setOnClickListener(this);
|
||||
basalTypeRadioGroup.setOnCheckedChangeListener(this);
|
||||
return view;
|
||||
}
|
||||
|
||||
|
@ -52,8 +84,8 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi
|
|||
switch (view.getId()) {
|
||||
case R.id.overview_newtempbasal_okbutton:
|
||||
try {
|
||||
int basalPercent = 100;
|
||||
Double basal = SafeParse.stringToDouble(basalEdit.getText().toString());
|
||||
int basalPercent = 0;
|
||||
Double basalAbsolute = 0d;
|
||||
final boolean setAsPercent = percentRadio.isChecked();
|
||||
int durationInMinutes = 30;
|
||||
if (h10Radio.isChecked()) durationInMinutes = 60;
|
||||
|
@ -63,22 +95,23 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi
|
|||
|
||||
String confirmMessage = getString(R.string.setbasalquestion);
|
||||
if (setAsPercent) {
|
||||
basalPercent = MainApp.getConfigBuilder().applyBasalConstraints(basal.intValue());
|
||||
confirmMessage += "\n " + basalPercent + "% ";
|
||||
confirmMessage += getString(R.string.duration) + " " + durationInMinutes + "min ?";
|
||||
if (basalPercent != basal.intValue())
|
||||
int basalPercentInput = SafeParse.stringToDouble(basalPercentEdit.getText().toString()).intValue();
|
||||
basalPercent = MainApp.getConfigBuilder().applyBasalConstraints(basalPercentInput);
|
||||
confirmMessage += "\n" + basalPercent + "% ";
|
||||
confirmMessage += "\n" + getString(R.string.duration) + " " + durationInMinutes + "min ?";
|
||||
if (basalPercent != basalPercentInput)
|
||||
confirmMessage += "\n" + getString(R.string.constraintapllied);
|
||||
} else {
|
||||
Double basalAfterConstraint = MainApp.getConfigBuilder().applyBasalConstraints(basal);
|
||||
confirmMessage += "\n " + basalAfterConstraint + " U/h ";
|
||||
confirmMessage += getString(R.string.duration) + " " + durationInMinutes + "min ?";
|
||||
if (basalAfterConstraint != basal)
|
||||
Double basalAbsoluteInput = SafeParse.stringToDouble(basalAbsoluteEdit.getText().toString());
|
||||
basalAbsolute = MainApp.getConfigBuilder().applyBasalConstraints(basalAbsoluteInput);
|
||||
confirmMessage += "\n" + basalAbsolute + " U/h ";
|
||||
confirmMessage += "\n" + getString(R.string.duration) + " " + durationInMinutes + "min ?";
|
||||
if (basalAbsolute - basalAbsoluteInput != 0d)
|
||||
confirmMessage += "\n" + getString(R.string.constraintapllied);
|
||||
basal = basalAfterConstraint;
|
||||
}
|
||||
|
||||
final int finalBasalPercent = basalPercent;
|
||||
final Double finalBasal = basal;
|
||||
final Double finalBasal = basalAbsolute;
|
||||
final int finalDurationInMinutes = durationInMinutes;
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this.getContext());
|
||||
|
@ -111,4 +144,18 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
||||
switch (checkedId) {
|
||||
case R.id.overview_newtempbasal_percent_radio:
|
||||
percentLayout.setVisibility(View.VISIBLE);
|
||||
absoluteLayout.setVisibility(View.GONE);
|
||||
break;
|
||||
case R.id.overview_newtempbasal_absolute_radio:
|
||||
percentLayout.setVisibility(View.GONE);
|
||||
absoluteLayout.setVisibility(View.VISIBLE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -317,7 +317,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
|
|||
if (calculatedTotalInsulin > 0d || calculatedCarbs > 0d) {
|
||||
String insulinText = calculatedTotalInsulin > 0d ? (numberFormat.format(calculatedTotalInsulin) + "U") : "";
|
||||
String carbsText = calculatedCarbs > 0d ? (intFormat.format(calculatedCarbs) + "g") : "";
|
||||
wizardDialogDeliverButton.setText("SEND " + insulinText + " " + carbsText);
|
||||
wizardDialogDeliverButton.setText(getString(R.string.send) + " " + insulinText + " " + carbsText);
|
||||
wizardDialogDeliverButton.setVisibility(Button.VISIBLE);
|
||||
} else {
|
||||
wizardDialogDeliverButton.setVisibility(Button.INVISIBLE);
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:text="NSClient version:" />
|
||||
android:text="@string/configbuilder_nsclientversion_label" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -42,7 +42,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:text="Nightscout version:" />
|
||||
android:text="@string/configbuilder_nightscoutversion_label" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
@ -12,24 +12,25 @@
|
|||
android:orientation="horizontal">
|
||||
|
||||
<RadioGroup
|
||||
android:id="@+id/overview_newtempbasal_radiogroup"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/overview_newtempbasal_percent"
|
||||
android:id="@+id/overview_newtempbasal_percent_radio"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/overview_newtempbasal_percent_label"
|
||||
android:layout_marginRight="20dp"
|
||||
android:checked="true"
|
||||
android:layout_marginRight="20dp" />
|
||||
android:text="@string/overview_newtempbasal_percent_label" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/overview_newtempbasal_absolute"
|
||||
android:id="@+id/overview_newtempbasal_absolute_radio"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="U/h"
|
||||
android:layout_marginLeft="20dp" />
|
||||
android:layout_marginLeft="20dp"
|
||||
android:text="U/h" />
|
||||
</RadioGroup>
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -47,16 +48,99 @@
|
|||
android:text="@string/overview_newtempbasal_basal_label"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||
|
||||
<LinearLayout
|
||||
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">
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/overview_newtempbasal_basalpercent_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"
|
||||
android:layout_weight="0.5" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/overview_newtempbasal_basal"
|
||||
android:id="@+id/overview_newtempbasal_basalpercentinput"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_weight="0.5"
|
||||
android:inputType="numberDecimal"
|
||||
android:minWidth="200dp"
|
||||
android:minWidth="100dp"
|
||||
android:padding="10dp"
|
||||
android:text=""
|
||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:gravity="center_horizontal" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/overview_newtempbasal_basalpercent_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"
|
||||
android:layout_weight="0.5" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
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">
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/overview_newtempbasal_basalabsolute_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"
|
||||
android:layout_weight="0.5" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/overview_newtempbasal_basalabsoluteinput"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_weight="0.5"
|
||||
android:inputType="numberDecimal"
|
||||
android:minWidth="100dp"
|
||||
android:padding="10dp"
|
||||
android:text=""
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:gravity="center_horizontal" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/overview_newtempbasal_basalabsolute_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"
|
||||
android:layout_weight="0.5" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<RadioGroup
|
||||
|
@ -65,35 +149,35 @@
|
|||
android:layout_gravity="center_horizontal">
|
||||
|
||||
<RadioButton
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="0.5 h"
|
||||
android:id="@+id/overview_newtempbasal_05h"
|
||||
android:checked="true" />
|
||||
|
||||
<RadioButton
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="1 h"
|
||||
android:id="@+id/overview_newtempbasal_1h" />
|
||||
android:checked="true"
|
||||
android:text="0.5 h" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/overview_newtempbasal_1h"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="2 h"
|
||||
android:id="@+id/overview_newtempbasal_2h" />
|
||||
android:text="1 h" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/overview_newtempbasal_2h"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="3 h"
|
||||
android:id="@+id/overview_newtempbasal_3h" />
|
||||
android:text="2 h" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/overview_newtempbasal_3h"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="4 h"
|
||||
android:id="@+id/overview_newtempbasal_4h" />
|
||||
android:text="3 h" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/overview_newtempbasal_4h"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="4 h" />
|
||||
</RadioGroup>
|
||||
|
||||
<Button
|
||||
|
|
|
@ -202,7 +202,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:text="@string/treatments_wizard_bg_label"
|
||||
android:width="50dp"
|
||||
android:width="80dp"
|
||||
android:id="@+id/textView" />
|
||||
|
||||
<TextView
|
||||
|
@ -237,7 +237,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:text="@string/treatments_wizard_carbs_label"
|
||||
android:width="50dp" />
|
||||
android:width="80dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -273,7 +273,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:text="@string/treatments_wizard_bolusiob_label"
|
||||
android:width="100dp" />
|
||||
android:width="130dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -309,7 +309,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:text="@string/treatments_wizard_basaliob_label"
|
||||
android:width="100dp" />
|
||||
android:width="130dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -343,7 +343,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:text="@string/treatments_wizard_correction_label"
|
||||
android:width="50dp" />
|
||||
android:width="80dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -378,7 +378,7 @@
|
|||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textStyle="bold"
|
||||
android:text="@string/treatments_wizard_total_label"
|
||||
android:width="50dp"
|
||||
android:width="80dp"
|
||||
android:height="30dp"
|
||||
android:gravity="center_vertical"
|
||||
android:textColor="@color/accent_material_light" />
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
<string name="closedloop">Uzavřená smyčka</string>
|
||||
<string name="openloop">Otevřená smyčka</string>
|
||||
<string name="alert">Výstaha</string>
|
||||
<string name="apsmode_summary">Typ smyčky</string>
|
||||
<string name="apsmode_title">Typ smyčky</string>
|
||||
<string name="avgdelta">Prům. změna</string>
|
||||
<string name="basal">Bazál</string>
|
||||
|
@ -193,4 +192,7 @@
|
|||
<string name="careportal_newnstreatment_glucosetype">Zadání glykémie</string>
|
||||
<string name="title_activity_main">AndroidAPS</string>
|
||||
<string name="openapsma">OpenAPS MA</string>
|
||||
<string name="configbuilder_nightscoutversion_label">Verze Nightscoutu:</string>
|
||||
<string name="configbuilder_nsclientversion_label">Verze NSClienta:</string>
|
||||
<string name="send">POSLAT</string>
|
||||
</resources>
|
|
@ -200,5 +200,8 @@
|
|||
<string name="noprofile">No profile loaded from NS yet</string>
|
||||
<string name="overview_tempbasal_button">TempBasal</string>
|
||||
<string name="overview_extendedbolus_button">Extended Bolus</string>
|
||||
<string name="configbuilder_nsclientversion_label">NSClient version:</string>
|
||||
<string name="configbuilder_nightscoutversion_label">Nightscout version:</string>
|
||||
<string name="send">SEND</string>
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue