Merge branch 'dev' into queue

This commit is contained in:
Milos Kozak 2017-11-22 19:44:16 +01:00
commit dfd0218a6a
8 changed files with 83 additions and 47 deletions

View file

@ -30,21 +30,21 @@ public class Profile {
private JSONObject json;
private String units = null;
double dia = Constants.defaultDIA;
TimeZone timeZone = TimeZone.getDefault();
JSONArray isf;
private double dia = Constants.defaultDIA;
private TimeZone timeZone = TimeZone.getDefault();
private JSONArray isf;
private LongSparseArray<Double> isf_v = null; // oldest at index 0
JSONArray ic;
private JSONArray ic;
private LongSparseArray<Double> ic_v = null; // oldest at index 0
JSONArray basal;
private JSONArray basal;
private LongSparseArray<Double> basal_v = null; // oldest at index 0
JSONArray targetLow;
private JSONArray targetLow;
private LongSparseArray<Double> targetLow_v = null; // oldest at index 0
JSONArray targetHigh;
private JSONArray targetHigh;
private LongSparseArray<Double> targetHigh_v = null; // oldest at index 0
int percentage = 100;
int timeshift = 0;
private int percentage = 100;
private int timeshift = 0;
public Profile(JSONObject json, String units) {
this(json, 100, 0);
@ -206,7 +206,7 @@ public class Profile {
return shiftedTime;
}
double getMultiplier(LongSparseArray<Double> array) {
private double getMultiplier(LongSparseArray<Double> array) {
double multiplier = 1d;
if (array == isf_v)
@ -220,7 +220,7 @@ public class Profile {
return multiplier;
}
double getMultiplier(JSONArray array) {
private double getMultiplier(JSONArray array) {
double multiplier = 1d;
if (array == isf)

View file

@ -32,6 +32,56 @@ public class PumpEnactResult extends Object {
public boolean queued = false;
public PumpEnactResult success(boolean success) {
this.success = success;
return this;
}
public PumpEnactResult enacted(boolean enacted) {
this.enacted = enacted;
return this;
}
public PumpEnactResult comment(String comment) {
this.comment = comment;
return this;
}
public PumpEnactResult duration(Integer duration) {
this.duration = duration;
return this;
}
public PumpEnactResult absolute(Double absolute) {
this.absolute = absolute;
return this;
}
public PumpEnactResult isPercent(boolean isPercent) {
this.isPercent = isPercent;
return this;
}
public PumpEnactResult isTempCancel(boolean isTempCancel) {
this.isTempCancel = isTempCancel;
return this;
}
public PumpEnactResult bolusDelivered(Double bolusDelivered) {
this.bolusDelivered = bolusDelivered;
return this;
}
public PumpEnactResult carbsDelivered(Double carbsDelivered) {
this.carbsDelivered = carbsDelivered;
return this;
}
public PumpEnactResult queued(boolean queued) {
this.queued = queued;
return this;
}
public String log() {
return "Success: " + success + " Enacted: " + enacted + " Comment: " + comment + " Duration: " + duration + " Absolute: " + absolute + " Percent: " + percent + " IsPercent: " + isPercent + " Queued: " + queued;
}
@ -89,31 +139,6 @@ public class PumpEnactResult extends Object {
public PumpEnactResult() {
}
public PumpEnactResult success(boolean success) {
this.success = success;
return this;
}
public PumpEnactResult enacted(boolean enacted) {
this.enacted = enacted;
return this;
}
public PumpEnactResult comment(String comment) {
this.comment = comment;
return this;
}
public PumpEnactResult absolute(double absolute) {
this.absolute = absolute;
return this;
}
public PumpEnactResult duration(int duration) {
this.duration = duration;
return this;
}
public JSONObject json() {
JSONObject result = new JSONObject();
try {

View file

@ -158,7 +158,7 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
tempBasal.setVisibility(View.GONE);
tempBasalCancel.setVisibility(View.VISIBLE);
final TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
tempBasalCancel.setText(MainApp.instance().getString(R.string.cancel) + "\n" + activeTemp.toStringShort());
tempBasalCancel.setText(MainApp.instance().getString(R.string.cancel) + " " + activeTemp.toStringShort());
} else {
tempBasal.setVisibility(View.VISIBLE);
tempBasalCancel.setVisibility(View.GONE);

View file

@ -414,7 +414,9 @@ public class ConfigBuilderPlugin implements PluginBase, ConstraintsInterface, Tr
}
return false;
}
} else if (isTempBasalInProgress() && Math.abs(request.rate - getTempBasalAbsoluteRateHistory()) < pump.getPumpDescription().basalStep) {
} else if (isTempBasalInProgress()
&& getTempBasalRemainingMinutesFromHistory() > 5
&& Math.abs(request.rate - getTempBasalAbsoluteRateHistory()) < pump.getPumpDescription().basalStep) {
if (Config.logCongigBuilderActions)
log.debug("applyAPSRequest: Temp basal set correctly");
if (callback != null) {

View file

@ -96,6 +96,7 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
case R.id.overview_bolusprogress_stop:
log.debug("Stop bolus delivery button pressed");
stopPressedView.setVisibility(View.VISIBLE);
stopButton.setVisibility(View.INVISIBLE);
ConfigBuilderPlugin.getActivePump().stopBolusDelivering();
break;
}

View file

@ -95,24 +95,27 @@ public class PersistentNotificationPlugin implements PluginBase {
@Override
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
if (getType() == type) {
this.fragmentEnabled = fragmentEnabled;
enableDisableNotification(fragmentEnabled);
checkBusRegistration();
//updateNotification();
}
}
}
private void updateNotification() {
private void enableDisableNotification(boolean fragmentEnabled) {
if (!fragmentEnabled) {
NotificationManager mNotificationManager =
(NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.cancel(ONGOING_NOTIFICATION_ID);
return;
} else {
updateNotification();
}
}
private void updateNotification() {
if (!fragmentEnabled) {
return;
}
String line1 = ctx.getString(R.string.noprofile);
@ -189,11 +192,16 @@ public class PersistentNotificationPlugin implements PluginBase {
private void checkBusRegistration() {
if (fragmentEnabled) {
try {
MainApp.bus().register(this);
} catch (IllegalArgumentException e) {
// already registered
}
} else {
try {
MainApp.bus().unregister(this);
} catch (Exception e) {
} catch (IllegalArgumentException e) {
// already unregistered
}
}
}

View file

@ -52,7 +52,7 @@ public class VirtualPumpFragment extends SubscriberFragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
try {
View view = inflater.inflate(R.layout.vitualpump_fragment, container, false);
View view = inflater.inflate(R.layout.virtualpump_fragment, container, false);
basaBasalRateView = (TextView) view.findViewById(R.id.virtualpump_basabasalrate);
tempBasalView = (TextView) view.findViewById(R.id.virtualpump_tempbasal);
extendedBolusView = (TextView) view.findViewById(R.id.virtualpump_extendedbolus);