Merge pull request #799 from jotomo/prime-fill-refresh
Prime/fill button refresh and some drive-by improvements
This commit is contained in:
commit
8c5a2ab524
|
@ -128,7 +128,7 @@ public class Treatment implements DataPointWithLabelInterface {
|
|||
@Override
|
||||
public String getLabel() {
|
||||
String label = "";
|
||||
if (insulin > 0) label += DecimalFormatter.to2Decimal(insulin) + "U";
|
||||
if (insulin > 0) label += DecimalFormatter.toPumpSupportedBolus(insulin) + "U";
|
||||
if (carbs > 0)
|
||||
label += "~" + DecimalFormatter.to0Decimal(carbs) + "g";
|
||||
return label;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package info.nightscout.androidaps.plugins.Actions.dialogs;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.text.Html;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
|
@ -13,17 +13,23 @@ import android.view.ViewGroup;
|
|||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
|
||||
import com.crashlytics.android.answers.CustomEvent;
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||
import info.nightscout.androidaps.db.CareportalEvent;
|
||||
import info.nightscout.androidaps.db.Source;
|
||||
import info.nightscout.androidaps.interfaces.Constraint;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
|
@ -31,6 +37,7 @@ import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity;
|
|||
import info.nightscout.androidaps.queue.Callback;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
import info.nightscout.utils.FabricPrivacy;
|
||||
import info.nightscout.utils.NSUpload;
|
||||
import info.nightscout.utils.NumberPicker;
|
||||
import info.nightscout.utils.SP;
|
||||
import info.nightscout.utils.SafeParse;
|
||||
|
@ -38,13 +45,13 @@ import info.nightscout.utils.SafeParse;
|
|||
public class FillDialog extends DialogFragment implements OnClickListener {
|
||||
private static Logger log = LoggerFactory.getLogger(FillDialog.class);
|
||||
|
||||
Button deliverButton;
|
||||
|
||||
double amount1 = 0d;
|
||||
double amount2 = 0d;
|
||||
double amount3 = 0d;
|
||||
|
||||
NumberPicker editInsulin;
|
||||
CheckBox pumpSiteChangeCheckbox;
|
||||
CheckBox insulinCartridgeChangeCheckbox;
|
||||
|
||||
public FillDialog() {
|
||||
}
|
||||
|
@ -54,22 +61,24 @@ public class FillDialog extends DialogFragment implements OnClickListener {
|
|||
Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.actions_fill_dialog, null, false);
|
||||
|
||||
deliverButton = (Button) view.findViewById(R.id.treatments_newtreatment_deliverbutton);
|
||||
view.findViewById(R.id.ok).setOnClickListener(this);
|
||||
view.findViewById(R.id.cancel).setOnClickListener(this);
|
||||
|
||||
deliverButton.setOnClickListener(this);
|
||||
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
|
||||
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
|
||||
|
||||
pumpSiteChangeCheckbox = view.findViewById(R.id.catheter_change);
|
||||
insulinCartridgeChangeCheckbox = view.findViewById(R.id.cartridge_change);
|
||||
|
||||
Double maxInsulin = MainApp.getConstraintChecker().getMaxBolusAllowed().value();
|
||||
double bolusstep = ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep;
|
||||
editInsulin = (NumberPicker) view.findViewById(R.id.treatments_newtreatment_insulinamount);
|
||||
editInsulin.setParams(0d, 0d, maxInsulin, bolusstep, new DecimalFormat("0.00"), false);
|
||||
editInsulin = view.findViewById(R.id.treatments_newtreatment_insulinamount);
|
||||
editInsulin.setParams(0d, 0d, maxInsulin, bolusstep, DecimalFormatter.pumpSupportedBolusFormat(), false);
|
||||
|
||||
//setup preset buttons
|
||||
Button button1 = (Button) view.findViewById(R.id.fill_preset_button1);
|
||||
Button button2 = (Button) view.findViewById(R.id.fill_preset_button2);
|
||||
Button button3 = (Button) view.findViewById(R.id.fill_preset_button3);
|
||||
View divider = view.findViewById(R.id.fill_preset_divider);
|
||||
|
||||
amount1 = SP.getDouble("fill_button1", 0.3);
|
||||
amount2 = SP.getDouble("fill_button2", 0d);
|
||||
|
@ -77,103 +86,109 @@ public class FillDialog extends DialogFragment implements OnClickListener {
|
|||
|
||||
if (amount1 > 0) {
|
||||
button1.setVisibility(View.VISIBLE);
|
||||
button1.setText(DecimalFormatter.to2Decimal(amount1) + "U");
|
||||
button1.setText(DecimalFormatter.toPumpSupportedBolus(amount1)); // + "U");
|
||||
button1.setOnClickListener(this);
|
||||
} else {
|
||||
button1.setVisibility(View.GONE);
|
||||
}
|
||||
if (amount2 > 0) {
|
||||
button2.setVisibility(View.VISIBLE);
|
||||
button2.setText(DecimalFormatter.to2Decimal(amount2) + "U");
|
||||
button2.setText(DecimalFormatter.toPumpSupportedBolus(amount2)); // + "U");
|
||||
button2.setOnClickListener(this);
|
||||
} else {
|
||||
button2.setVisibility(View.GONE);
|
||||
}
|
||||
if (amount3 > 0) {
|
||||
button3.setVisibility(View.VISIBLE);
|
||||
button3.setText(DecimalFormatter.to2Decimal(amount3) + "U");
|
||||
button3.setText(DecimalFormatter.toPumpSupportedBolus(amount3)); // + "U");
|
||||
button3.setOnClickListener(this);
|
||||
} else {
|
||||
button3.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (button1.getVisibility() == View.GONE && button2.getVisibility() == View.GONE && button3.getVisibility() == View.GONE) {
|
||||
divider.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
setCancelable(true);
|
||||
getDialog().setCanceledOnTouchOutside(false);
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (getDialog() != null)
|
||||
getDialog().getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.treatments_newtreatment_deliverbutton:
|
||||
Double insulin = SafeParse.stringToDouble(editInsulin.getText().toString());
|
||||
confirmAndDeliver(insulin);
|
||||
case R.id.ok:
|
||||
confirmAndDeliver();
|
||||
break;
|
||||
case R.id.cancel:
|
||||
dismiss();
|
||||
break;
|
||||
case R.id.fill_preset_button1:
|
||||
confirmAndDeliver(amount1);
|
||||
editInsulin.setValue(amount1);
|
||||
break;
|
||||
case R.id.fill_preset_button2:
|
||||
confirmAndDeliver(amount2);
|
||||
editInsulin.setValue(amount2);
|
||||
break;
|
||||
case R.id.fill_preset_button3:
|
||||
confirmAndDeliver(amount3);
|
||||
editInsulin.setValue(amount3);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void confirmAndDeliver(Double insulin) {
|
||||
private void confirmAndDeliver() {
|
||||
try {
|
||||
Double insulin = SafeParse.stringToDouble(editInsulin.getText());
|
||||
|
||||
String confirmMessage = getString(R.string.fillwarning) + "\n";
|
||||
List<String> confirmMessage = new LinkedList<>();
|
||||
|
||||
Double insulinAfterConstraints = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(insulin)).value();
|
||||
confirmMessage += getString(R.string.bolus) + ": " + insulinAfterConstraints + "U";
|
||||
if (insulinAfterConstraints - insulin != 0)
|
||||
confirmMessage += "\n" + getString(R.string.constraintapllied);
|
||||
if (insulinAfterConstraints > 0) {
|
||||
confirmMessage.add(MainApp.gs(R.string.fillwarning));
|
||||
confirmMessage.add("");
|
||||
confirmMessage.add(MainApp.gs(R.string.bolus) + ": " + "<font color='" + MainApp.gc(R.color.colorCarbsButton) + "'>" + insulinAfterConstraints + "U" + "</font>");
|
||||
if (!insulinAfterConstraints.equals(insulin))
|
||||
confirmMessage.add("<font color='" + MainApp.sResources.getColor(R.color.low) + "'>" + MainApp.gs(R.string.bolusconstraintapplied) + "</font>");
|
||||
}
|
||||
|
||||
if (pumpSiteChangeCheckbox.isChecked())
|
||||
confirmMessage.add("" + "<font color='" + MainApp.sResources.getColor(R.color.high) + "'>" + getString(R.string.record_pump_site_change) + "</font>");
|
||||
|
||||
if (insulinCartridgeChangeCheckbox.isChecked())
|
||||
confirmMessage.add("" + "<font color='" + MainApp.sResources.getColor(R.color.high) + "'>" + getString(R.string.record_insulin_cartridge_change) + "</font>");
|
||||
|
||||
final Double finalInsulinAfterConstraints = insulinAfterConstraints;
|
||||
|
||||
final Context context = getContext();
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
|
||||
builder.setTitle(this.getContext().getString(R.string.confirmation));
|
||||
builder.setMessage(confirmMessage);
|
||||
builder.setPositiveButton(getString(R.string.primefill), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
if (finalInsulinAfterConstraints > 0) {
|
||||
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
|
||||
detailedBolusInfo.insulin = finalInsulinAfterConstraints;
|
||||
detailedBolusInfo.context = context;
|
||||
detailedBolusInfo.source = Source.USER;
|
||||
detailedBolusInfo.isValid = false; // do not count it in IOB (for pump history)
|
||||
ConfigBuilderPlugin.getCommandQueue().bolus(detailedBolusInfo, 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.sResources.getString(R.string.treatmentdeliveryerror));
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
MainApp.instance().startActivity(i);
|
||||
}
|
||||
if (confirmMessage.isEmpty())
|
||||
confirmMessage.add(MainApp.gs(R.string.no_action_selected));
|
||||
|
||||
builder.setTitle(MainApp.gs(R.string.confirmation));
|
||||
builder.setMessage(Html.fromHtml(Joiner.on("<br/>").join(confirmMessage)));
|
||||
builder.setPositiveButton(getString(R.string.primefill), (dialog, id) -> {
|
||||
if (finalInsulinAfterConstraints > 0) {
|
||||
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
|
||||
detailedBolusInfo.insulin = finalInsulinAfterConstraints;
|
||||
detailedBolusInfo.context = context;
|
||||
detailedBolusInfo.source = Source.USER;
|
||||
detailedBolusInfo.isValid = false; // do not count it in IOB (for pump history)
|
||||
ConfigBuilderPlugin.getCommandQueue().bolus(detailedBolusInfo, 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.sResources.getString(R.string.treatmentdeliveryerror));
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
MainApp.instance().startActivity(i);
|
||||
}
|
||||
});
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("Fill"));
|
||||
}
|
||||
}
|
||||
});
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("Fill"));
|
||||
}
|
||||
long now = System.currentTimeMillis();
|
||||
if (pumpSiteChangeCheckbox.isChecked()) NSUpload.uploadEvent(CareportalEvent.SITECHANGE, now);
|
||||
if (insulinCartridgeChangeCheckbox.isChecked()) NSUpload.uploadEvent(CareportalEvent.INSULINCHANGE, now + 1000);
|
||||
});
|
||||
builder.setNegativeButton(getString(R.string.cancel), null);
|
||||
builder.show();
|
||||
|
|
|
@ -62,7 +62,7 @@ public class APSResult {
|
|||
|
||||
// smb
|
||||
if (smb != 0)
|
||||
ret += ("SMB: " + DecimalFormatter.to2Decimal(smb) + " U\n");
|
||||
ret += ("SMB: " + DecimalFormatter.toPumpSupportedBolus(smb) + " U\n");
|
||||
|
||||
// reason
|
||||
ret += MainApp.sResources.getString(R.string.reason) + ": " + reason;
|
||||
|
@ -87,7 +87,7 @@ public class APSResult {
|
|||
|
||||
// smb
|
||||
if (smb != 0)
|
||||
ret += ("<b>" + "SMB" + "</b>: " + DecimalFormatter.to2Decimal(smb) + " U<br>");
|
||||
ret += ("<b>" + "SMB" + "</b>: " + DecimalFormatter.toPumpSupportedBolus(smb) + " U<br>");
|
||||
|
||||
// reason
|
||||
ret += "<b>" + MainApp.sResources.getString(R.string.reason) + "</b>: " + reason.replace("<", "<").replace(">", ">");
|
||||
|
|
|
@ -48,6 +48,7 @@ import info.nightscout.androidaps.interfaces.Constraint;
|
|||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.queue.Callback;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
import info.nightscout.utils.NumberPicker;
|
||||
import info.nightscout.utils.SP;
|
||||
import info.nightscout.utils.SafeParse;
|
||||
|
@ -124,7 +125,7 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener,
|
|||
|
||||
editInsulin = (NumberPicker) view.findViewById(R.id.treatments_newinsulin_amount);
|
||||
|
||||
editInsulin.setParams(0d, 0d, maxInsulin, ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep, new DecimalFormat("0.00"), false, textWatcher);
|
||||
editInsulin.setParams(0d, 0d, maxInsulin, ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep, DecimalFormatter.pumpSupportedBolusFormat(), false, textWatcher);
|
||||
|
||||
dateButton = (TextView) view.findViewById(R.id.newinsulin_eventdate);
|
||||
timeButton = (TextView) view.findViewById(R.id.newinsulin_eventtime);
|
||||
|
@ -160,7 +161,8 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener,
|
|||
}
|
||||
|
||||
private String toSignedString(double value) {
|
||||
return value > 0 ? "+" + value : String.valueOf(value);
|
||||
String formatted = DecimalFormatter.toPumpSupportedBolus(value);
|
||||
return value > 0 ? "+" + formatted : formatted;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -243,7 +243,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
|||
editBg.setParams(0d, 0d, 500d, 0.1d, new DecimalFormat("0.0"), false, textWatcher);
|
||||
editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, textWatcher);
|
||||
double bolusstep = ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep;
|
||||
editCorr.setParams(0d, -maxCorrection, maxCorrection, bolusstep, new DecimalFormat("0.00"), false, textWatcher);
|
||||
editCorr.setParams(0d, -maxCorrection, maxCorrection, bolusstep, DecimalFormatter.pumpSupportedBolusFormat(), false, textWatcher);
|
||||
editCarbTime.setParams(0d, -60d, 60d, 5d, new DecimalFormat("0"), false);
|
||||
initDialog();
|
||||
|
||||
|
@ -260,19 +260,13 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
|||
}
|
||||
|
||||
private void saveCheckedStates() {
|
||||
//SP.putBoolean(getString(R.string.key_wizard_include_bg), bgCheckbox.isChecked());
|
||||
SP.putBoolean(getString(R.string.key_wizard_include_cob), cobCheckbox.isChecked());
|
||||
SP.putBoolean(getString(R.string.key_wizard_include_trend_bg), bgtrendCheckbox.isChecked());
|
||||
//SP.putBoolean(getString(R.string.key_wizard_include_bolus_iob), bolusIobCheckbox.isChecked());
|
||||
//SP.putBoolean(getString(R.string.key_wizard_include_basal_iob), basalIobCheckbox.isChecked());
|
||||
}
|
||||
|
||||
private void loadCheckedStates() {
|
||||
//bgCheckbox.setChecked(SP.getBoolean(getString(R.string.key_wizard_include_bg), true));
|
||||
bgtrendCheckbox.setChecked(SP.getBoolean(getString(R.string.key_wizard_include_trend_bg), false));
|
||||
cobCheckbox.setChecked(SP.getBoolean(getString(R.string.key_wizard_include_cob), false));
|
||||
//bolusIobCheckbox.setChecked(SP.getBoolean(getString(R.string.key_wizard_include_bolus_iob), true));
|
||||
//basalIobCheckbox.setChecked(SP.getBoolean(getString(R.string.key_wizard_include_basal_iob), true));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -534,7 +528,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
|||
}
|
||||
|
||||
if (calculatedTotalInsulin > 0d || calculatedCarbs > 0d) {
|
||||
String insulinText = calculatedTotalInsulin > 0d ? (DecimalFormatter.to2Decimal(calculatedTotalInsulin) + "U") : "";
|
||||
String insulinText = calculatedTotalInsulin > 0d ? (DecimalFormatter.toPumpSupportedBolus(calculatedTotalInsulin) + "U") : "";
|
||||
String carbsText = calculatedCarbs > 0d ? (DecimalFormatter.to0Decimal(calculatedCarbs) + "g") : "";
|
||||
total.setText(MainApp.gs(R.string.result) + ": " + insulinText + " " + carbsText);
|
||||
okButton.setVisibility(View.VISIBLE);
|
||||
|
|
|
@ -1197,7 +1197,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
quickWizardButton.setVisibility(View.VISIBLE);
|
||||
String text = quickWizardEntry.buttonText() + "\n" + DecimalFormatter.to0Decimal(quickWizardEntry.carbs()) + "g";
|
||||
BolusWizard wizard = quickWizardEntry.doCalc(profile, tempTarget, lastBG, false);
|
||||
text += " " + DecimalFormatter.to2Decimal(wizard.calculatedTotalInsulin) + "U";
|
||||
text += " " + DecimalFormatter.toPumpSupportedBolus(wizard.calculatedTotalInsulin) + "U";
|
||||
quickWizardButton.setText(text);
|
||||
if (wizard.calculatedTotalInsulin <= 0)
|
||||
quickWizardButton.setVisibility(View.GONE);
|
||||
|
|
|
@ -98,7 +98,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
|
|||
pumpDescription.basalStep = 0.01d;
|
||||
pumpDescription.basalMinimumRate = 0.01d;
|
||||
|
||||
pumpDescription.isRefillingCapable = false;
|
||||
pumpDescription.isRefillingCapable = true;
|
||||
|
||||
pumpDescription.storesCarbInfo = false;
|
||||
pumpDescription.is30minBasalRatesCapable = true;
|
||||
|
|
|
@ -76,7 +76,7 @@ public class TreatmentsBolusFragment extends SubscriberFragment implements View.
|
|||
return;
|
||||
Treatment t = treatments.get(position);
|
||||
holder.date.setText(DateUtil.dateAndTimeString(t.date));
|
||||
holder.insulin.setText(DecimalFormatter.to2Decimal(t.insulin) + " U");
|
||||
holder.insulin.setText(DecimalFormatter.toPumpSupportedBolus(t.insulin) + " U");
|
||||
holder.carbs.setText(DecimalFormatter.to0Decimal(t.carbs) + " g");
|
||||
Iob iob = t.iobCalc(System.currentTimeMillis(), profile.getDia());
|
||||
holder.iob.setText(DecimalFormatter.to2Decimal(iob.iobContrib) + " U");
|
||||
|
|
|
@ -80,7 +80,7 @@ public class TreatmentsExtendedBolusesFragment extends SubscriberFragment {
|
|||
holder.date.setText(DateUtil.dateAndTimeString(extendedBolus.date) + " - " + DateUtil.timeString(extendedBolus.end()));
|
||||
}
|
||||
holder.duration.setText(DecimalFormatter.to0Decimal(extendedBolus.durationInMinutes) + " min");
|
||||
holder.insulin.setText(DecimalFormatter.to2Decimal(extendedBolus.insulin) + " U");
|
||||
holder.insulin.setText(DecimalFormatter.toPumpSupportedBolus(extendedBolus.insulin) + " U");
|
||||
holder.realDuration.setText(DecimalFormatter.to0Decimal(extendedBolus.getRealDuration()) + " min");
|
||||
IobTotal iob = extendedBolus.iobCalc(System.currentTimeMillis());
|
||||
holder.iob.setText(DecimalFormatter.to2Decimal(iob.iob) + " U");
|
||||
|
|
|
@ -2,6 +2,8 @@ package info.nightscout.utils;
|
|||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
|
||||
/**
|
||||
* Created by mike on 11.07.2016.
|
||||
*/
|
||||
|
@ -26,4 +28,16 @@ public class DecimalFormatter {
|
|||
public static String to3Decimal(double value) {
|
||||
return format3dec.format(value);
|
||||
}
|
||||
|
||||
public static String toPumpSupportedBolus(double value) {
|
||||
return ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep <= 0.01
|
||||
? to2Decimal(value)
|
||||
: to1Decimal(value);
|
||||
}
|
||||
|
||||
public static DecimalFormat pumpSupportedBolusFormat() {
|
||||
return ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep <= 0.01
|
||||
? new DecimalFormat("0.00")
|
||||
: new DecimalFormat("0.0");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -475,6 +475,27 @@ public class NSUpload {
|
|||
}
|
||||
}
|
||||
|
||||
public static void uploadEvent(String careportalEvent, long time) {
|
||||
Context context = MainApp.instance().getApplicationContext();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("action", "dbAdd");
|
||||
bundle.putString("collection", "treatments");
|
||||
JSONObject data = new JSONObject();
|
||||
try {
|
||||
data.put("eventType", careportalEvent);
|
||||
data.put("created_at", DateUtil.toISOString(time));
|
||||
data.put("enteredBy", SP.getString("careportal_enteredby", MainApp.gs(R.string.app_name)));
|
||||
} catch (JSONException e) {
|
||||
log.error("Unhandled exception", e);
|
||||
}
|
||||
bundle.putString("data", data.toString());
|
||||
Intent intent = new Intent(Intents.ACTION_DATABASE);
|
||||
intent.putExtras(bundle);
|
||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
context.sendBroadcast(intent);
|
||||
DbLogger.dbAdd(intent, data.toString());
|
||||
}
|
||||
|
||||
public static void removeFoodFromNS(String _id) {
|
||||
try {
|
||||
Context context = MainApp.instance().getApplicationContext();
|
||||
|
|
|
@ -1,110 +1,97 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:focusableInTouchMode="true"
|
||||
android:orientation="vertical"
|
||||
android:padding="10dp">
|
||||
<ScrollView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/careportal_newnstreatment_insulin_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:width="120dp"
|
||||
android:padding="10dp"
|
||||
android:text="@string/treatments_newtreatment_insulinamount_label"
|
||||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
android:orientation="vertical"
|
||||
android:focusableInTouchMode="true"
|
||||
android:padding="10dp">
|
||||
|
||||
<info.nightscout.utils.NumberPicker
|
||||
android:id="@+id/treatments_newtreatment_insulinamount"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp" />
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:padding="5dp"
|
||||
android:text="@string/primefill"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:textColor="@color/colorInsulinButton" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="left"
|
||||
android:minWidth="45dp"
|
||||
android:paddingLeft="5dp"
|
||||
android:text="U"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="5dp"
|
||||
android:padding="5dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:src="@drawable/icon_cp_pump_canula" />
|
||||
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:id="@+id/careportal_newnstreatment_insulin_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginRight="20dp"
|
||||
android:orientation="horizontal"
|
||||
android:padding="10dp">
|
||||
<CheckBox
|
||||
android:id="@+id/catheter_change"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="5dp"
|
||||
android:text="Pump site change" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/treatments_newtreatment_deliverbutton"
|
||||
style="?android:attr/buttonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:padding="10dp"
|
||||
android:text="@string/primefill"
|
||||
android:textSize="20sp" />
|
||||
<CheckBox
|
||||
android:id="@+id/cartridge_change"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:text="Insulin cartridge change" />
|
||||
|
||||
</LinearLayout>
|
||||
<info.nightscout.utils.NumberPicker
|
||||
android:id="@+id/treatments_newtreatment_insulinamount"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_gravity="end"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_marginLeft="30dp"
|
||||
android:layout_marginRight="30dp"
|
||||
android:layout_marginTop="10dp" />
|
||||
|
||||
<View
|
||||
android:id="@+id/fill_preset_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@android:color/darker_gray"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginRight="20dp"
|
||||
android:orientation="horizontal"
|
||||
android:padding="10dp"
|
||||
android:gravity="center_horizontal"
|
||||
android:layout_gravity="center_horizontal">
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="5dp">
|
||||
|
||||
<Button
|
||||
android:id="@+id/fill_preset_button1"
|
||||
style="?android:attr/buttonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.3"
|
||||
android:padding="10dp"
|
||||
android:text="0.3U"
|
||||
android:textSize="20sp" />
|
||||
<Button
|
||||
android:id="@+id/fill_preset_button2"
|
||||
style="?android:attr/buttonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.3"
|
||||
android:padding="10dp"
|
||||
android:text="0.7U"
|
||||
android:textSize="20sp" />
|
||||
<Button
|
||||
android:id="@+id/fill_preset_button3"
|
||||
style="?android:attr/buttonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.3"
|
||||
android:padding="10dp"
|
||||
android:text="1.2U"
|
||||
android:textSize="20sp" />
|
||||
<Button
|
||||
android:id="@+id/fill_preset_button1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:text="0.3U" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/fill_preset_button2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:text="0.7U" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/fill_preset_button3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:text="1.2U" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<include layout="@layout/mdtp_done_button" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
|
|
@ -101,7 +101,7 @@
|
|||
android:layout_marginRight="10dp"
|
||||
android:layout_marginTop="3dp"
|
||||
android:layout_weight="0.5"
|
||||
android:drawableTop="@drawable/icon_actions_refill"
|
||||
android:drawableTop="@drawable/icon_cp_pump_canula"
|
||||
android:text="@string/primefill" />
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -11,7 +9,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:focusableInTouchMode="true"
|
||||
|
|
|
@ -989,5 +989,7 @@
|
|||
<string name="key_treatmentssafety_maxcarbs">treatmentssafety_maxcarbs</string>
|
||||
<string name="unsafeusage">unsafe usage</string>
|
||||
<string name="key_openapsama_useautosens" translatable="false">openapsama_useautosens</string>
|
||||
<string name="record_pump_site_change">Record pump site change</string>
|
||||
<string name="record_insulin_cartridge_change">Record insulin cartridge change</string>
|
||||
</resources>
|
||||
|
||||
|
|
Loading…
Reference in a new issue