fix merge conflict
This commit is contained in:
commit
c36587430c
|
@ -22,12 +22,12 @@ public class DetailedBolusInfo {
|
||||||
public double insulin = 0;
|
public double insulin = 0;
|
||||||
public double carbs = 0;
|
public double carbs = 0;
|
||||||
public int source = Source.NONE;
|
public int source = Source.NONE;
|
||||||
|
public boolean isValid = true;
|
||||||
public double glucose = 0; // Bg value in current units
|
public double glucose = 0; // Bg value in current units
|
||||||
public String glucoseType = ""; // NS values: Manual, Finger, Sensor
|
public String glucoseType = ""; // NS values: Manual, Finger, Sensor
|
||||||
public int carbTime = 0; // time shift of carbs in minutes
|
public int carbTime = 0; // time shift of carbs in minutes
|
||||||
public JSONObject boluscalc = null; // additional bolus wizard info
|
public JSONObject boluscalc = null; // additional bolus wizard info
|
||||||
public Context context = null; // context for progress dialog
|
public Context context = null; // context for progress dialog
|
||||||
public boolean addToTreatments = true;
|
|
||||||
public long pumpId = 0; // id of record if comming from pump history (not a newly created treatment)
|
public long pumpId = 0; // id of record if comming from pump history (not a newly created treatment)
|
||||||
public boolean isSMB = false; // is a Super-MicroBolus
|
public boolean isSMB = false; // is a Super-MicroBolus
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ public class OverlappingIntervals<T extends Interval> extends Intervals<T> {
|
||||||
boolean needToCut = false;
|
boolean needToCut = false;
|
||||||
long cutTime = 0;
|
long cutTime = 0;
|
||||||
|
|
||||||
for (int index = rawData.size()-1; index > 0; index--) { //begin with newest
|
for (int index = rawData.size()-1; index >= 0; index--) { //begin with newest
|
||||||
Interval cur = rawData.valueAt(index);
|
Interval cur = rawData.valueAt(index);
|
||||||
if (cur.isEndingEvent()){
|
if (cur.isEndingEvent()){
|
||||||
needToCut = true;
|
needToCut = true;
|
||||||
|
|
|
@ -598,6 +598,16 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
scheduleTreatmentChange();
|
scheduleTreatmentChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void update(Treatment treatment) {
|
||||||
|
try {
|
||||||
|
getDaoTreatments().update(treatment);
|
||||||
|
updateEarliestDataChange(treatment.date);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
scheduleTreatmentChange();
|
||||||
|
}
|
||||||
|
|
||||||
public void deleteTreatmentById(String _id) {
|
public void deleteTreatmentById(String _id) {
|
||||||
Treatment stored = findTreatmentById(_id);
|
Treatment stored = findTreatmentById(_id);
|
||||||
if (stored != null) {
|
if (stored != null) {
|
||||||
|
|
|
@ -181,6 +181,8 @@ public class Treatment implements DataPointWithLabelInterface {
|
||||||
// ----------------- DataPointInterface end --------------------
|
// ----------------- DataPointInterface end --------------------
|
||||||
|
|
||||||
public Iob iobCalc(long time, double dia) {
|
public Iob iobCalc(long time, double dia) {
|
||||||
|
if (!isValid)
|
||||||
|
return new Iob();
|
||||||
InsulinInterface insulinInterface = MainApp.getInsulinIterfaceById(insulinInterfaceID);
|
InsulinInterface insulinInterface = MainApp.getInsulinIterfaceById(insulinInterfaceID);
|
||||||
if (insulinInterface == null)
|
if (insulinInterface == null)
|
||||||
insulinInterface = ConfigBuilderPlugin.getActiveInsulin();
|
insulinInterface = ConfigBuilderPlugin.getActiveInsulin();
|
||||||
|
|
|
@ -215,7 +215,7 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case R.id.actions_canceltempbasal:
|
case R.id.actions_canceltempbasal:
|
||||||
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
|
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
|
||||||
sHandler.post(new Runnable() {
|
sHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
|
@ -164,8 +164,8 @@ public class FillDialog extends DialogFragment implements OnClickListener {
|
||||||
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
|
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
|
||||||
detailedBolusInfo.insulin = finalInsulinAfterConstraints;
|
detailedBolusInfo.insulin = finalInsulinAfterConstraints;
|
||||||
detailedBolusInfo.context = context;
|
detailedBolusInfo.context = context;
|
||||||
detailedBolusInfo.addToTreatments = false;
|
|
||||||
detailedBolusInfo.source = Source.NONE;
|
detailedBolusInfo.source = Source.NONE;
|
||||||
|
detailedBolusInfo.isValid = false; // do not count it in IOB (for pump history)
|
||||||
PumpEnactResult result = pump.deliverTreatment(detailedBolusInfo);
|
PumpEnactResult result = pump.deliverTreatment(detailedBolusInfo);
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||||
|
|
|
@ -884,10 +884,8 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
||||||
@Override
|
@Override
|
||||||
// return true if new record is created
|
// return true if new record is created
|
||||||
public boolean addToHistoryTreatment(DetailedBolusInfo detailedBolusInfo) {
|
public boolean addToHistoryTreatment(DetailedBolusInfo detailedBolusInfo) {
|
||||||
if (!detailedBolusInfo.addToTreatments)
|
|
||||||
return false;
|
|
||||||
boolean newRecordCreated = activeTreatments.addToHistoryTreatment(detailedBolusInfo);
|
boolean newRecordCreated = activeTreatments.addToHistoryTreatment(detailedBolusInfo);
|
||||||
if (newRecordCreated)
|
if (newRecordCreated && detailedBolusInfo.isValid)
|
||||||
NSUpload.uploadBolusWizardRecord(detailedBolusInfo);
|
NSUpload.uploadBolusWizardRecord(detailedBolusInfo);
|
||||||
return newRecordCreated;
|
return newRecordCreated;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,7 @@ public class Notification {
|
||||||
public static final int NSALARM = 19;
|
public static final int NSALARM = 19;
|
||||||
public static final int NSURGENTALARM = 20;
|
public static final int NSURGENTALARM = 20;
|
||||||
public static final int SHORT_DIA = 21;
|
public static final int SHORT_DIA = 21;
|
||||||
|
public static final int TOAST_ALARM = 22;
|
||||||
|
|
||||||
|
|
||||||
public int id;
|
public int id;
|
||||||
|
|
|
@ -1597,7 +1597,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
List<Treatment> treatments = MainApp.getConfigBuilder().getTreatmentsFromHistory();
|
List<Treatment> treatments = MainApp.getConfigBuilder().getTreatmentsFromHistory();
|
||||||
|
|
||||||
for (int tx = 0; tx < treatments.size(); tx++) {
|
for (int tx = 0; tx < treatments.size(); tx++) {
|
||||||
DataPointWithLabelInterface t = treatments.get(tx);
|
Treatment t = treatments.get(tx);
|
||||||
|
if (!t.isValid)
|
||||||
|
continue;
|
||||||
if (t.getX() < fromTime || t.getX() > endTime) continue;
|
if (t.getX() < fromTime || t.getX() > endTime) continue;
|
||||||
t.setY(getNearestBg((long) t.getX(), bgReadingsArray));
|
t.setY(getNearestBg((long) t.getX(), bgReadingsArray));
|
||||||
filteredTreatments.add(t);
|
filteredTreatments.add(t);
|
||||||
|
|
|
@ -99,14 +99,14 @@ public class MsgHistoryEvents_v2 extends MessageBase {
|
||||||
MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus);
|
MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus);
|
||||||
break;
|
break;
|
||||||
case DanaRPump.BOLUS:
|
case DanaRPump.BOLUS:
|
||||||
log.debug("EVENT BOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min");
|
|
||||||
detailedBolusInfo.insulin = param1 / 100d;
|
detailedBolusInfo.insulin = param1 / 100d;
|
||||||
MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
|
boolean newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
|
||||||
|
log.debug((newRecord ? "**NEW** " : "") + "EVENT BOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min");
|
||||||
break;
|
break;
|
||||||
case DanaRPump.DUALBOLUS:
|
case DanaRPump.DUALBOLUS:
|
||||||
log.debug("EVENT DUALBOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min");
|
|
||||||
detailedBolusInfo.insulin = param1 / 100d;
|
detailedBolusInfo.insulin = param1 / 100d;
|
||||||
MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
|
newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
|
||||||
|
log.debug((newRecord ? "**NEW** " : "") + "EVENT DUALBOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min");
|
||||||
break;
|
break;
|
||||||
case DanaRPump.DUALEXTENDEDSTART:
|
case DanaRPump.DUALEXTENDEDSTART:
|
||||||
log.debug("EVENT DUALEXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min");
|
log.debug("EVENT DUALEXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min");
|
||||||
|
@ -134,9 +134,9 @@ public class MsgHistoryEvents_v2 extends MessageBase {
|
||||||
log.debug("EVENT PROFILECHANGE (" + recordCode + ") " + datetime.toLocaleString() + " No: " + param1 + " CurrentRate: " + (param2 / 100d) + "U/h");
|
log.debug("EVENT PROFILECHANGE (" + recordCode + ") " + datetime.toLocaleString() + " No: " + param1 + " CurrentRate: " + (param2 / 100d) + "U/h");
|
||||||
break;
|
break;
|
||||||
case DanaRPump.CARBS:
|
case DanaRPump.CARBS:
|
||||||
log.debug("EVENT CARBS (" + recordCode + ") " + datetime.toLocaleString() + " Carbs: " + param1 + "g");
|
|
||||||
detailedBolusInfo.carbs = param1;
|
detailedBolusInfo.carbs = param1;
|
||||||
MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
|
newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
|
||||||
|
log.debug((newRecord ? "**NEW** " : "") + "EVENT CARBS (" + recordCode + ") " + datetime.toLocaleString() + " Carbs: " + param1 + "g");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
log.debug("Event: " + recordCode + " " + datetime.toLocaleString() + " Param1: " + param1 + " Param2: " + param2);
|
log.debug("Event: " + recordCode + " " + datetime.toLocaleString() + " Param1: " + param1 + " Param2: " + param2);
|
||||||
|
|
|
@ -179,6 +179,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
||||||
|
|
||||||
for (Integer pos = 0; pos < treatments.size(); pos++) {
|
for (Integer pos = 0; pos < treatments.size(); pos++) {
|
||||||
Treatment t = treatments.get(pos);
|
Treatment t = treatments.get(pos);
|
||||||
|
if (!t.isValid) continue;
|
||||||
if (t.date > time) continue;
|
if (t.date > time) continue;
|
||||||
Iob tIOB = t.iobCalc(time, dia);
|
Iob tIOB = t.iobCalc(time, dia);
|
||||||
total.iob += tIOB.iobContrib;
|
total.iob += tIOB.iobContrib;
|
||||||
|
@ -224,6 +225,8 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
||||||
long dia_ago = now - (new Double(1.5d * profile.getDia() * 60 * 60 * 1000l)).longValue();
|
long dia_ago = now - (new Double(1.5d * profile.getDia() * 60 * 60 * 1000l)).longValue();
|
||||||
|
|
||||||
for (Treatment treatment : treatments) {
|
for (Treatment treatment : treatments) {
|
||||||
|
if (!treatment.isValid)
|
||||||
|
continue;
|
||||||
long t = treatment.date;
|
long t = treatment.date;
|
||||||
if (t > dia_ago && t <= now) {
|
if (t > dia_ago && t <= now) {
|
||||||
if (treatment.carbs >= 1) {
|
if (treatment.carbs >= 1) {
|
||||||
|
@ -253,6 +256,8 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
||||||
List<Treatment> in5minback = new ArrayList<>();
|
List<Treatment> in5minback = new ArrayList<>();
|
||||||
for (Integer pos = 0; pos < treatments.size(); pos++) {
|
for (Integer pos = 0; pos < treatments.size(); pos++) {
|
||||||
Treatment t = treatments.get(pos);
|
Treatment t = treatments.get(pos);
|
||||||
|
if (!t.isValid)
|
||||||
|
continue;
|
||||||
if (t.date <= time && t.date > time - 5 * 60 * 1000 && t.carbs > 0)
|
if (t.date <= time && t.date > time - 5 * 60 * 1000 && t.carbs > 0)
|
||||||
in5minback.add(t);
|
in5minback.add(t);
|
||||||
}
|
}
|
||||||
|
@ -412,6 +417,8 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
||||||
treatment.source = detailedBolusInfo.source;
|
treatment.source = detailedBolusInfo.source;
|
||||||
treatment.pumpId = detailedBolusInfo.pumpId;
|
treatment.pumpId = detailedBolusInfo.pumpId;
|
||||||
treatment.insulin = detailedBolusInfo.insulin;
|
treatment.insulin = detailedBolusInfo.insulin;
|
||||||
|
treatment.isValid = detailedBolusInfo.isValid;
|
||||||
|
treatment.isSMB = detailedBolusInfo.isSMB;
|
||||||
if (detailedBolusInfo.carbTime == 0)
|
if (detailedBolusInfo.carbTime == 0)
|
||||||
treatment.carbs = detailedBolusInfo.carbs;
|
treatment.carbs = detailedBolusInfo.carbs;
|
||||||
treatment.source = detailedBolusInfo.source;
|
treatment.source = detailedBolusInfo.source;
|
||||||
|
|
|
@ -0,0 +1,113 @@
|
||||||
|
package info.nightscout.androidaps.plugins.Treatments.fragments;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.DialogFragment;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.data.Profile;
|
||||||
|
import info.nightscout.androidaps.db.ProfileSwitch;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpDanaR.Dialogs.ProfileViewDialog;
|
||||||
|
import info.nightscout.utils.DateUtil;
|
||||||
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by adrian on 17/08/17.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class ProfileViewerDialog extends DialogFragment {
|
||||||
|
|
||||||
|
private long time;
|
||||||
|
|
||||||
|
private static Logger log = LoggerFactory.getLogger(ProfileViewDialog.class);
|
||||||
|
|
||||||
|
private static TextView noProfile;
|
||||||
|
private static TextView units;
|
||||||
|
private static TextView dia;
|
||||||
|
private static TextView activeProfile;
|
||||||
|
private static TextView ic;
|
||||||
|
private static TextView isf;
|
||||||
|
private static TextView basal;
|
||||||
|
private static TextView target;
|
||||||
|
private static View dateDelimiter;
|
||||||
|
private static LinearLayout dateLayout;
|
||||||
|
private static TextView dateTextView;
|
||||||
|
private static Button refreshButton;
|
||||||
|
|
||||||
|
static ProfileViewerDialog newInstance(long time) {
|
||||||
|
ProfileViewerDialog dialog = new ProfileViewerDialog();
|
||||||
|
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putLong("time", time);
|
||||||
|
dialog.setArguments(args);
|
||||||
|
|
||||||
|
return dialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
time = getArguments().getLong("time");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
View layout = inflater.inflate(R.layout.nsprofileviewer_fragment, container, false);
|
||||||
|
|
||||||
|
noProfile = (TextView) layout.findViewById(R.id.profileview_noprofile);
|
||||||
|
units = (TextView) layout.findViewById(R.id.profileview_units);
|
||||||
|
dia = (TextView) layout.findViewById(R.id.profileview_dia);
|
||||||
|
activeProfile = (TextView) layout.findViewById(R.id.profileview_activeprofile);
|
||||||
|
ic = (TextView) layout.findViewById(R.id.profileview_ic);
|
||||||
|
isf = (TextView) layout.findViewById(R.id.profileview_isf);
|
||||||
|
basal = (TextView) layout.findViewById(R.id.profileview_basal);
|
||||||
|
target = (TextView) layout.findViewById(R.id.profileview_target);
|
||||||
|
refreshButton = (Button) layout.findViewById(R.id.profileview_reload);
|
||||||
|
refreshButton.setVisibility(View.GONE);
|
||||||
|
dateDelimiter = layout.findViewById(R.id.profileview_datedelimiter);
|
||||||
|
dateDelimiter.setVisibility(View.VISIBLE);
|
||||||
|
dateLayout = (LinearLayout) layout.findViewById(R.id.profileview_datelayout);
|
||||||
|
dateLayout.setVisibility(View.VISIBLE);
|
||||||
|
dateTextView = (TextView) layout.findViewById(R.id.profileview_date);
|
||||||
|
|
||||||
|
setContent();
|
||||||
|
return layout;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setContent() {
|
||||||
|
Profile profile = null;
|
||||||
|
ProfileSwitch profileSwitch = MainApp.getConfigBuilder().getProfileSwitchFromHistory(time);
|
||||||
|
if(profileSwitch!=null){
|
||||||
|
profile = profileSwitch.getProfileObject();
|
||||||
|
}
|
||||||
|
if (profile != null) {
|
||||||
|
noProfile.setVisibility(View.GONE);
|
||||||
|
units.setText(profile.getUnits());
|
||||||
|
dia.setText(DecimalFormatter.to2Decimal(profile.getDia()) + " h");
|
||||||
|
activeProfile.setText(profileSwitch.profileName);
|
||||||
|
dateTextView.setText(DateUtil.dateAndTimeString(profileSwitch.date));
|
||||||
|
ic.setText(profile.getIcList());
|
||||||
|
isf.setText(profile.getIsfList());
|
||||||
|
basal.setText(profile.getBasalList());
|
||||||
|
target.setText(profile.getTargetList());
|
||||||
|
} else {
|
||||||
|
noProfile.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -85,6 +85,7 @@ public class TreatmentsBolusFragment extends SubscriberFragment implements View.
|
||||||
holder.mealOrCorrection.setText(t.mealBolus ? MainApp.sResources.getString(R.string.mealbolus) : MainApp.sResources.getString(R.string.correctionbous));
|
holder.mealOrCorrection.setText(t.mealBolus ? MainApp.sResources.getString(R.string.mealbolus) : MainApp.sResources.getString(R.string.correctionbous));
|
||||||
holder.ph.setVisibility(t.source == Source.PUMP ? View.VISIBLE : View.GONE);
|
holder.ph.setVisibility(t.source == Source.PUMP ? View.VISIBLE : View.GONE);
|
||||||
holder.ns.setVisibility(t._id != null ? View.VISIBLE : View.GONE);
|
holder.ns.setVisibility(t._id != null ? View.VISIBLE : View.GONE);
|
||||||
|
holder.invalid.setVisibility(t.isValid ? View.GONE : View.VISIBLE);
|
||||||
if (iob.iobContrib != 0)
|
if (iob.iobContrib != 0)
|
||||||
holder.iob.setTextColor(ContextCompat.getColor(MainApp.instance(), R.color.colorActive));
|
holder.iob.setTextColor(ContextCompat.getColor(MainApp.instance(), R.color.colorActive));
|
||||||
else
|
else
|
||||||
|
@ -113,6 +114,7 @@ public class TreatmentsBolusFragment extends SubscriberFragment implements View.
|
||||||
TextView remove;
|
TextView remove;
|
||||||
TextView ph;
|
TextView ph;
|
||||||
TextView ns;
|
TextView ns;
|
||||||
|
TextView invalid;
|
||||||
|
|
||||||
TreatmentsViewHolder(View itemView) {
|
TreatmentsViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
|
@ -125,6 +127,7 @@ public class TreatmentsBolusFragment extends SubscriberFragment implements View.
|
||||||
mealOrCorrection = (TextView) itemView.findViewById(R.id.treatments_mealorcorrection);
|
mealOrCorrection = (TextView) itemView.findViewById(R.id.treatments_mealorcorrection);
|
||||||
ph = (TextView) itemView.findViewById(R.id.pump_sign);
|
ph = (TextView) itemView.findViewById(R.id.pump_sign);
|
||||||
ns = (TextView) itemView.findViewById(R.id.ns_sign);
|
ns = (TextView) itemView.findViewById(R.id.ns_sign);
|
||||||
|
invalid = (TextView) itemView.findViewById(R.id.invalid_sign);
|
||||||
remove = (TextView) itemView.findViewById(R.id.treatments_remove);
|
remove = (TextView) itemView.findViewById(R.id.treatments_remove);
|
||||||
remove.setOnClickListener(this);
|
remove.setOnClickListener(this);
|
||||||
remove.setPaintFlags(remove.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
remove.setPaintFlags(remove.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
||||||
|
@ -141,10 +144,15 @@ public class TreatmentsBolusFragment extends SubscriberFragment implements View.
|
||||||
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
final String _id = treatment._id;
|
final String _id = treatment._id;
|
||||||
if (_id != null && !_id.equals("")) {
|
if (treatment.source == Source.PUMP) {
|
||||||
NSUpload.removeCareportalEntryFromNS(_id);
|
treatment.isValid = false;
|
||||||
|
MainApp.getDbHelper().update(treatment);
|
||||||
|
} else {
|
||||||
|
if (_id != null && !_id.equals("")) {
|
||||||
|
NSUpload.removeCareportalEntryFromNS(_id);
|
||||||
|
}
|
||||||
|
MainApp.getDbHelper().delete(treatment);
|
||||||
}
|
}
|
||||||
MainApp.getDbHelper().delete(treatment);
|
|
||||||
updateGUI();
|
updateGUI();
|
||||||
Answers.getInstance().logCustom(new CustomEvent("RemoveTreatment"));
|
Answers.getInstance().logCustom(new CustomEvent("RemoveTreatment"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import android.content.Intent;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.support.v4.app.FragmentManager;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.support.v7.widget.CardView;
|
import android.support.v7.widget.CardView;
|
||||||
|
@ -84,6 +85,9 @@ public class TreatmentsProfileSwitchFragment extends SubscriberFragment implemen
|
||||||
else
|
else
|
||||||
holder.date.setTextColor(holder.duration.getCurrentTextColor());
|
holder.date.setTextColor(holder.duration.getCurrentTextColor());
|
||||||
holder.remove.setTag(profileSwitch);
|
holder.remove.setTag(profileSwitch);
|
||||||
|
holder.name.setTag(profileSwitch);
|
||||||
|
holder.date.setTag(profileSwitch);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -116,6 +120,9 @@ public class TreatmentsProfileSwitchFragment extends SubscriberFragment implemen
|
||||||
remove = (TextView) itemView.findViewById(R.id.profileswitch_remove);
|
remove = (TextView) itemView.findViewById(R.id.profileswitch_remove);
|
||||||
remove.setOnClickListener(this);
|
remove.setOnClickListener(this);
|
||||||
remove.setPaintFlags(remove.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
remove.setPaintFlags(remove.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
||||||
|
name.setOnClickListener(this);
|
||||||
|
date.setOnClickListener(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -134,6 +141,13 @@ public class TreatmentsProfileSwitchFragment extends SubscriberFragment implemen
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
case R.id.profileswitch_date:
|
||||||
|
case R.id.profileswitch_name:
|
||||||
|
long time = ((ProfileSwitch)v.getTag()).date;
|
||||||
|
ProfileViewerDialog pvd = ProfileViewerDialog.newInstance(time);
|
||||||
|
FragmentManager manager = getFragmentManager();
|
||||||
|
pvd.show(manager, "ProfileViewDialog");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -615,7 +615,7 @@ public class ActionStringHandler {
|
||||||
public void run() {
|
public void run() {
|
||||||
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
|
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
|
||||||
detailedBolusInfo.insulin = amount;
|
detailedBolusInfo.insulin = amount;
|
||||||
detailedBolusInfo.addToTreatments = false;
|
detailedBolusInfo.isValid = false;
|
||||||
detailedBolusInfo.source = Source.USER;
|
detailedBolusInfo.source = Source.USER;
|
||||||
PumpEnactResult result = MainApp.getConfigBuilder().deliverTreatment(detailedBolusInfo);
|
PumpEnactResult result = MainApp.getConfigBuilder().deliverTreatment(detailedBolusInfo);
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
|
|
|
@ -85,12 +85,16 @@ public class DateUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int toSeconds(String hh_colon_mm) {
|
public static int toSeconds(String hh_colon_mm) {
|
||||||
Pattern p = Pattern.compile("(\\d+):(\\d+)");
|
Pattern p = Pattern.compile("(\\d+):(\\d+)( a.m.| p.m.|)");
|
||||||
Matcher m = p.matcher(hh_colon_mm);
|
Matcher m = p.matcher(hh_colon_mm);
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
|
|
||||||
if (m.find()) {
|
if (m.find()) {
|
||||||
retval = SafeParse.stringToInt(m.group(1)) * 60 * 60 + SafeParse.stringToInt(m.group(2)) * 60;
|
retval = SafeParse.stringToInt(m.group(1)) * 60 * 60 + SafeParse.stringToInt(m.group(2)) * 60;
|
||||||
|
if (m.group(3).equals(" .a.m") && m.group(1).equals("12"))
|
||||||
|
retval -= 12 * 60 * 60;
|
||||||
|
if (m.group(3).equals(" p.m.") && !m.group(1).equals("12"))
|
||||||
|
retval += 12 * 60 * 60;
|
||||||
}
|
}
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,10 @@ import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.plugins.Overview.Notification;
|
||||||
|
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||||
|
|
||||||
|
|
||||||
public class ToastUtils {
|
public class ToastUtils {
|
||||||
public static void showToastInUiThread(final Context ctx,
|
public static void showToastInUiThread(final Context ctx,
|
||||||
|
@ -25,6 +29,13 @@ public class ToastUtils {
|
||||||
|
|
||||||
showToastInUiThread(ctx, string);
|
showToastInUiThread(ctx, string);
|
||||||
playSound(ctx, soundID);
|
playSound(ctx, soundID);
|
||||||
|
new Thread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Notification notification = new Notification(Notification.TOAST_ALARM, string, Notification.URGENT);
|
||||||
|
MainApp.bus().post(new EventNewNotification(notification));
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void playSound(final Context ctx, final int soundID) {
|
private static void playSound(final Context ctx, final int soundID) {
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
android:layout_weight="2"
|
android:layout_weight="2"
|
||||||
android:gravity="end"
|
android:gravity="end"
|
||||||
android:paddingRight="5dp"
|
android:paddingRight="5dp"
|
||||||
android:text="@string/nsprofileview_activeprofile_label"
|
android:text="@string/careportal_newnstreatment_profile_label"
|
||||||
android:textSize="14sp" />
|
android:textSize="14sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -60,6 +60,55 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="2dip"
|
||||||
|
android:layout_marginBottom="5dp"
|
||||||
|
android:layout_marginLeft="20dp"
|
||||||
|
android:layout_marginRight="20dp"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:background="@color/listdelimiter"
|
||||||
|
android:id="@+id/profileview_datedelimiter"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:id="@+id/profileview_datelayout"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="2"
|
||||||
|
android:gravity="end"
|
||||||
|
android:paddingRight="5dp"
|
||||||
|
android:text="@string/date"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="5dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:paddingEnd="2dp"
|
||||||
|
android:paddingStart="2dp"
|
||||||
|
android:text=":"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/profileview_date"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="start"
|
||||||
|
android:paddingLeft="5dp"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="2dip"
|
android:layout_height="2dip"
|
||||||
|
|
|
@ -375,7 +375,8 @@
|
||||||
android:id="@+id/overview_accepttemplayout"
|
android:id="@+id/overview_accepttemplayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/overview_accepttempbutton"
|
android:id="@+id/overview_accepttempbutton"
|
||||||
|
@ -386,8 +387,7 @@
|
||||||
android:layout_marginTop="3dp"
|
android:layout_marginTop="3dp"
|
||||||
android:layout_weight="0.5"
|
android:layout_weight="0.5"
|
||||||
android:text="Accept new temp\n0.25U/h"
|
android:text="Accept new temp\n0.25U/h"
|
||||||
android:textColor="@color/colorAcceptTempButton"
|
android:textColor="@color/colorAcceptTempButton" />
|
||||||
android:visibility="gone" />
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
|
|
@ -80,7 +80,6 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_marginRight="30dp"
|
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -106,6 +105,14 @@
|
||||||
android:text="NS"
|
android:text="NS"
|
||||||
android:textColor="@color/colorSetTempButton" />
|
android:textColor="@color/colorSetTempButton" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/invalid_sign"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginRight="10dp"
|
||||||
|
android:text="@string/invalid"
|
||||||
|
android:textColor="@android:color/holo_red_light" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
|
|
@ -707,5 +707,7 @@
|
||||||
<string name="ultrarapid_oref">Ultra-Rapid Oref</string>
|
<string name="ultrarapid_oref">Ultra-Rapid Oref</string>
|
||||||
<string name="dia_too_short" formatted="false">"DIA of %s too short - using %s instead!"</string>
|
<string name="dia_too_short" formatted="false">"DIA of %s too short - using %s instead!"</string>
|
||||||
<string name="activate_profile">ACTIVATE PROFILE</string>
|
<string name="activate_profile">ACTIVATE PROFILE</string>
|
||||||
|
<string name="date">Date</string>
|
||||||
|
<string name="invalid">INVALID</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue