Merge pull request #30 from jotomo/csv2-staging

Csv2 staging
This commit is contained in:
Johannes Mockenhaupt 2017-12-26 11:02:38 +01:00 committed by GitHub
commit 7163162743
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
55 changed files with 362 additions and 191 deletions

View file

@ -124,18 +124,11 @@ Usage:
both of these issues can be resolved in future versions.
Known issues:
- On phones with low memory (or aggressive power saving settings), Android may kill
AAPS frequently (if the buttons on the overview screen aren't displayed when opening
AAPS, the app was started again after Android killed it).
This may trigger false 'pump unreachable alarms' on start.
See the Combo tab's "last connection" field to check when the pump was last connected.
This may drain the pump's battery quicker since on startup the basal profile is read
from the pump. This may also increase the chance to hit the bug that makes the pump
reject all incoming connections until a button on the pump is pressed.
- Occasionally (every couple of days or less) AAPS might fail to automatically cancel
a TBR CANCELLED alert and needs to be dealt with (press the refresh button in AAPS
to transfer the warning to AAPS or confirm the alert on the pump). Similarly, the
'pump unreachable' bug may occur from time to time.
- Occasionally (every couple of days or so) AAPS might fail to automatically cancel
a TBR CANCELLED alert the user then needs to deal with (press the refresh button in AAPS
to transfer the warning to AAPS or confirm the alert on the pump).
- Similarly, the 'pump unreachable' bug may occur from time to time, which requires confirming
the alert on the pump to get the pump to accept connections again.
- Overall the integration seems rather robust, but there are limits to the way the
pump is controlled and how stable BT is, so there will be minor issues like the above
from time to time, though they're small compared to what works well.

View file

@ -192,4 +192,7 @@ dependencies {
compile 'com.google.code.gson:gson:2.7'
compile 'com.google.guava:guava:20.0'
compile project(path: ':ruffyscripter')
compile 'net.danlew:android.joda:2.9.9.1'
testCompile 'joda-time:joda-time:2.9.4.2'
}

View file

@ -15,6 +15,8 @@ import com.squareup.otto.Bus;
import com.squareup.otto.LoggingBus;
import com.squareup.otto.ThreadEnforcer;
import net.danlew.android.joda.JodaTimeAndroid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -97,6 +99,7 @@ public class MainApp extends Application {
super.onCreate();
Fabric.with(this, new Crashlytics());
Fabric.with(this, new Answers());
JodaTimeAndroid.init(this);
Crashlytics.setString("BUILDVERSION", BuildConfig.BUILDVERSION);
log.info("Version: " + BuildConfig.VERSION_NAME);
log.info("BuildVersion: " + BuildConfig.BUILDVERSION);

View file

@ -17,6 +17,9 @@ import java.util.TimeZone;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
@ -327,8 +330,27 @@ public class Profile {
}
public Double getBasal(Integer timeAsSeconds) {
if (basal_v == null)
if (basal_v == null) {
basal_v = convertToSparseArray(basal);
// Check for minimal basal value
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
if (pump != null) {
PumpDescription description = pump.getPumpDescription();
for (int i = 0; i < basal_v.size(); i++) {
if (basal_v.valueAt(i) < description.basalMinimumRate) {
basal_v.setValueAt(i, description.basalMinimumRate);
MainApp.bus().post(new EventNewNotification(new Notification(Notification.MINIMAL_BASAL_VALUE_REPLACED, MainApp.sResources.getString(R.string.minimalbasalvaluereplaced), Notification.NORMAL)));
}
}
return getValueToTime(basal_v, timeAsSeconds);
} else {
// if pump not available (at start)
// do not store converted array
Double value = getValueToTime(basal_v, timeAsSeconds);
basal_v = null;
return value;
}
}
return getValueToTime(basal_v, timeAsSeconds);
}

View file

@ -46,6 +46,7 @@ import info.nightscout.androidaps.events.EventTreatmentChange;
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventNewHistoryData;
import info.nightscout.androidaps.plugins.PumpDanaR.activities.DanaRNSHistorySync;
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
import info.nightscout.utils.PercentageSplitter;
public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
private static Logger log = LoggerFactory.getLogger(DatabaseHelper.class);
@ -1633,6 +1634,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
}
}
}
// look for already added percentage from NS
profileSwitch.profileName = PercentageSplitter.pureName(profileSwitch.profileName);
getDaoProfileSwitch().create(profileSwitch);
log.debug("PROFILESWITCH: New record from: " + Source.getString(profileSwitch.source) + " " + profileSwitch.toString());
scheduleProfileSwitchChange();

View file

@ -21,5 +21,5 @@ public interface InsulinInterface {
String getFriendlyName();
String getComment();
double getDia();
public Iob iobCalcForTreatment(Treatment treatment, long time, Double dia);
public Iob iobCalcForTreatment(Treatment treatment, long time, double dia);
}

View file

@ -38,7 +38,7 @@ public interface PumpInterface {
PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo);
void stopBolusDelivering();
PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, boolean enforceNew);
PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes);
PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, boolean enforceNew);
PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes);
//some pumps might set a very short temp close to 100% as cancelling a temp can be noisy
//when the cancel request is requested by the user (forced), the pump should always do a real cancel

View file

@ -8,7 +8,6 @@ import android.support.v4.app.FragmentManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import com.crashlytics.android.Crashlytics;
import com.crashlytics.android.answers.Answers;
@ -33,6 +32,7 @@ import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialo
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.utils.SingleClickButton;
/**
* A simple {@link Fragment} subclass.
@ -45,13 +45,13 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
return actionsPlugin;
}
Button profileSwitch;
Button tempTarget;
Button extendedBolus;
Button extendedBolusCancel;
Button tempBasal;
Button tempBasalCancel;
Button fill;
SingleClickButton profileSwitch;
SingleClickButton tempTarget;
SingleClickButton extendedBolus;
SingleClickButton extendedBolusCancel;
SingleClickButton tempBasal;
SingleClickButton tempBasalCancel;
SingleClickButton fill;
public ActionsFragment() {
super();
@ -64,13 +64,13 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
try {
View view = inflater.inflate(R.layout.actions_fragment, container, false);
profileSwitch = (Button) view.findViewById(R.id.actions_profileswitch);
tempTarget = (Button) view.findViewById(R.id.actions_temptarget);
extendedBolus = (Button) view.findViewById(R.id.actions_extendedbolus);
extendedBolusCancel = (Button) view.findViewById(R.id.actions_extendedbolus_cancel);
tempBasal = (Button) view.findViewById(R.id.actions_settempbasal);
tempBasalCancel = (Button) view.findViewById(R.id.actions_canceltempbasal);
fill = (Button) view.findViewById(R.id.actions_fill);
profileSwitch = (SingleClickButton) view.findViewById(R.id.actions_profileswitch);
tempTarget = (SingleClickButton) view.findViewById(R.id.actions_temptarget);
extendedBolus = (SingleClickButton) view.findViewById(R.id.actions_extendedbolus);
extendedBolusCancel = (SingleClickButton) view.findViewById(R.id.actions_extendedbolus_cancel);
tempBasal = (SingleClickButton) view.findViewById(R.id.actions_settempbasal);
tempBasalCancel = (SingleClickButton) view.findViewById(R.id.actions_canceltempbasal);
fill = (SingleClickButton) view.findViewById(R.id.actions_fill);
profileSwitch.setOnClickListener(this);
tempTarget.setOnClickListener(this);

View file

@ -100,6 +100,8 @@ public class FillDialog extends DialogFragment implements OnClickListener {
if (button1.getVisibility() == View.GONE && button2.getVisibility() == View.GONE && button3.getVisibility() == View.GONE) {
divider.setVisibility(View.GONE);
}
setCancelable(false);
return view;
}

View file

@ -54,14 +54,9 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli
view.findViewById(R.id.ok).setOnClickListener(this);
view.findViewById(R.id.cancel).setOnClickListener(this);
return view;
}
@Override
public void onResume() {
super.onResume();
if (getDialog() != null)
getDialog().getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
setCancelable(false);
return view;
}
@Override

View file

@ -102,6 +102,8 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi
view.findViewById(R.id.ok).setOnClickListener(this);
view.findViewById(R.id.cancel).setOnClickListener(this);
basalTypeRadioGroup.setOnCheckedChangeListener(this);
setCancelable(false);
return view;
}
@ -155,7 +157,7 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi
}
};
if (setAsPercent) {
ConfigBuilderPlugin.getCommandQueue().tempBasalPercent(finalBasalPercent, finalDurationInMinutes, callback);
ConfigBuilderPlugin.getCommandQueue().tempBasalPercent(finalBasalPercent, finalDurationInMinutes, true, callback);
} else {
ConfigBuilderPlugin.getCommandQueue().tempBasalAbsolute(finalBasal, finalDurationInMinutes, true, callback);
}

View file

@ -175,7 +175,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
profileSpinner.setAdapter(adapter);
// set selected to actual profile
for (int p = 0; p < profileList.size(); p++) {
if (profileList.get(p).equals(MainApp.getConfigBuilder().getProfileName()))
if (profileList.get(p).equals(MainApp.getConfigBuilder().getProfileName(false)))
profileSpinner.setSelection(p);
}
@ -360,6 +360,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_reuse_layout), options.profile && ps != null && ps.isCPP);
showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_temptarget_layout), options.tempTarget);
setCancelable(false);
return view;
}

View file

@ -736,6 +736,10 @@ public class ConfigBuilderPlugin implements PluginBase, ConstraintsInterface, Tr
return getProfileName(System.currentTimeMillis());
}
public String getProfileName(boolean customized) {
return getProfileName(System.currentTimeMillis(), customized);
}
public String getProfileName(long time) {
return getProfileName(time, true);
}

View file

@ -107,7 +107,7 @@ public class InsulinFastactingPlugin implements PluginBase, InsulinInterface {
}
@Override
public Iob iobCalcForTreatment(Treatment treatment, long time, Double dia) {
public Iob iobCalcForTreatment(Treatment treatment, long time, double dia) {
Iob result = new Iob();
double scaleFactor = 3.0 / dia;

View file

@ -107,7 +107,7 @@ public class InsulinFastactingProlongedPlugin implements PluginBase, InsulinInte
}
@Override
public Iob iobCalcForTreatment(Treatment treatment, long time, Double dia) {
public Iob iobCalcForTreatment(Treatment treatment, long time, double dia) {
Iob result = new Iob();
//Double scaleFactor = 3.0 / dia;

View file

@ -64,7 +64,7 @@ public abstract class InsulinOrefBasePlugin implements PluginBase, InsulinInterf
}
@Override
public Iob iobCalcForTreatment(Treatment treatment, long time, Double dia) {
public Iob iobCalcForTreatment(Treatment treatment, long time, double dia) {
Iob result = new Iob();
int peak = getPeak();

View file

@ -364,6 +364,8 @@ public class IobCobCalculatorPlugin implements PluginBase {
// check if data already exists
long bgTime = bucketed_data.get(i).date;
bgTime = roundUpTime(bgTime);
if (bgTime > System.currentTimeMillis())
continue;
Profile profile = MainApp.getConfigBuilder().getProfile(bgTime);
AutosensData existing;

View file

@ -76,6 +76,7 @@ public class CalibrationDialog extends DialogFragment implements View.OnClickLis
unitsView = (TextView) view.findViewById(R.id.overview_calibration_units);
unitsView.setText(units);
setCancelable(false);
return view;
}

View file

@ -101,6 +101,7 @@ public class NewTreatmentDialog extends DialogFragment implements OnClickListene
editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, textWatcher);
editInsulin.setParams(0d, 0d, maxInsulin, ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep, new DecimalFormat("0.00"), false, textWatcher);
setCancelable(false);
return view;
}

View file

@ -53,6 +53,8 @@ import info.nightscout.androidaps.db.TempTarget;
import info.nightscout.androidaps.events.EventNewBG;
import info.nightscout.androidaps.events.EventRefreshOverview;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin;
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui;
@ -251,6 +253,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
editCarbTime.setParams(0d, -60d, 60d, 5d, new DecimalFormat("0"), false);
initDialog();
setCancelable(false);
return view;
}
@ -344,7 +347,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
activeloop.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000);
MainApp.bus().post(new EventRefreshOverview("WizardDialog"));
}
ConfigBuilderPlugin.getCommandQueue().tempBasalAbsolute(0d, 120, true, new Callback() {
ConfigBuilderPlugin.getCommandQueue().tempBasalPercent(0, 120, true, new Callback() {
@Override
public void run() {
if (!result.success) {
@ -439,7 +442,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
basalIobInsulin.setText(DecimalFormatter.to2Decimal(-basalIob.basaliob) + "U");
// COB only if AMA is selected
if (ConfigBuilderPlugin.getActiveAPS() instanceof OpenAPSAMAPlugin && ConfigBuilderPlugin.getActiveAPS().getLastAPSResult() != null && ConfigBuilderPlugin.getActiveAPS().getLastAPSRun().after(new Date(System.currentTimeMillis() - 11 * 60 * 1000L))) {
if (ConfigBuilderPlugin.getActiveAPS() instanceof OpenAPSAMAPlugin) {
cobLayout.setVisibility(View.VISIBLE);
cobAvailable = true;
} else {
@ -483,12 +486,10 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
// COB
Double c_cob = 0d;
if (cobAvailable && cobCheckbox.isChecked()) {
if (ConfigBuilderPlugin.getActiveAPS().getLastAPSResult() != null && ConfigBuilderPlugin.getActiveAPS().getLastAPSRun().after(new Date(System.currentTimeMillis() - 11 * 60 * 1000L))) {
try {
c_cob = SafeParse.stringToDouble(ConfigBuilderPlugin.getActiveAPS().getLastAPSResult().json().getString("COB"));
} catch (JSONException e) {
log.error("Unhandled exception", e);
}
AutosensData autosensData = IobCobCalculatorPlugin.getAutosensData(System.currentTimeMillis());
if(autosensData != null && autosensData.time > System.currentTimeMillis() - 11 * 60 * 1000L) {
c_cob = autosensData.cob;
}
}

View file

@ -53,7 +53,6 @@ import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import info.nightscout.androidaps.BuildConfig;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
@ -79,6 +78,7 @@ import info.nightscout.androidaps.events.EventTempBasalChange;
import info.nightscout.androidaps.events.EventTempTargetChange;
import info.nightscout.androidaps.events.EventTreatmentChange;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
@ -113,6 +113,7 @@ import info.nightscout.utils.NSUpload;
import info.nightscout.utils.OKDialog;
import info.nightscout.utils.Profiler;
import info.nightscout.utils.SP;
import info.nightscout.utils.SingleClickButton;
import info.nightscout.utils.ToastUtils;
public class OverviewFragment extends Fragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener {
@ -156,11 +157,11 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
LinearLayoutManager llm;
LinearLayout acceptTempLayout;
Button treatmentButton;
Button wizardButton;
Button calibrationButton;
Button acceptTempButton;
Button quickWizardButton;
SingleClickButton treatmentButton;
SingleClickButton wizardButton;
SingleClickButton calibrationButton;
SingleClickButton acceptTempButton;
SingleClickButton quickWizardButton;
CheckBox lockScreen;
@ -244,16 +245,16 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
bgGraph = (GraphView) view.findViewById(R.id.overview_bggraph);
iobGraph = (GraphView) view.findViewById(R.id.overview_iobgraph);
treatmentButton = (Button) view.findViewById(R.id.overview_treatmentbutton);
treatmentButton = (SingleClickButton) view.findViewById(R.id.overview_treatmentbutton);
treatmentButton.setOnClickListener(this);
wizardButton = (Button) view.findViewById(R.id.overview_wizardbutton);
wizardButton = (SingleClickButton) view.findViewById(R.id.overview_wizardbutton);
wizardButton.setOnClickListener(this);
acceptTempButton = (Button) view.findViewById(R.id.overview_accepttempbutton);
acceptTempButton = (SingleClickButton) view.findViewById(R.id.overview_accepttempbutton);
if (acceptTempButton != null)
acceptTempButton.setOnClickListener(this);
quickWizardButton = (Button) view.findViewById(R.id.overview_quickwizardbutton);
quickWizardButton = (SingleClickButton) view.findViewById(R.id.overview_quickwizardbutton);
quickWizardButton.setOnClickListener(this);
calibrationButton = (Button) view.findViewById(R.id.overview_calibrationbutton);
calibrationButton = (SingleClickButton) view.findViewById(R.id.overview_calibrationbutton);
if (calibrationButton != null)
calibrationButton.setOnClickListener(this);
@ -320,6 +321,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
return view;
} catch (Exception e) {
Crashlytics.logException(e);
log.debug("Runtime Exception", e);
}
return null;
@ -331,6 +333,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
super.onCreateContextMenu(menu, v, menuInfo);
if (v == apsModeView) {
final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
final PumpDescription pumpDescription = ConfigBuilderPlugin.getActivePump().getPumpDescription();
if (activeloop == null)
return;
menu.setHeaderTitle(MainApp.sResources.getString(R.string.loop));
@ -341,7 +344,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
menu.add(MainApp.sResources.getString(R.string.suspendloopfor2h));
menu.add(MainApp.sResources.getString(R.string.suspendloopfor3h));
menu.add(MainApp.sResources.getString(R.string.suspendloopfor10h));
menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor30m));
if (pumpDescription.tempDurationStep <= 30)
menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor30m));
menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor1h));
menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor2h));
menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor3h));
@ -480,7 +484,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor30m))) {
activeloop.disconnectTo(System.currentTimeMillis() + 30L * 60 * 1000);
updateGUI("suspendmenu");
ConfigBuilderPlugin.getCommandQueue().tempBasalAbsolute(0d, 30, true, new Callback() {
ConfigBuilderPlugin.getCommandQueue().tempBasalPercent(0, 30, true, new Callback() {
@Override
public void run() {
if (!result.success) {
@ -493,7 +497,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor1h))) {
activeloop.disconnectTo(System.currentTimeMillis() + 1 * 60L * 60 * 1000);
updateGUI("suspendmenu");
ConfigBuilderPlugin.getCommandQueue().tempBasalAbsolute(0d, 60, true, new Callback() {
ConfigBuilderPlugin.getCommandQueue().tempBasalPercent(0, 60, true, new Callback() {
@Override
public void run() {
if (!result.success) {
@ -506,7 +510,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor2h))) {
activeloop.disconnectTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000);
updateGUI("suspendmenu");
ConfigBuilderPlugin.getCommandQueue().tempBasalAbsolute(0d, 2 * 60, true, new Callback() {
ConfigBuilderPlugin.getCommandQueue().tempBasalPercent(0, 2 * 60, true, new Callback() {
@Override
public void run() {
if (!result.success) {
@ -519,7 +523,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor3h))) {
activeloop.disconnectTo(System.currentTimeMillis() + 3 * 60L * 60 * 1000);
updateGUI("suspendmenu");
ConfigBuilderPlugin.getCommandQueue().tempBasalAbsolute(0d, 3 * 60, true, new Callback() {
ConfigBuilderPlugin.getCommandQueue().tempBasalPercent(0, 3 * 60, true, new Callback() {
@Override
public void run() {
if (!result.success) {

View file

@ -57,6 +57,7 @@ public class Notification {
public static final int PUMP_UNREACHABLE = 26;
public static final int BG_READINGS_MISSED = 27;
public static final int UNSUPPORTED_FIRMWARE = 28;
public static final int MINIMAL_BASAL_VALUE_REPLACED = 29;
public int id;
public Date date;

View file

@ -23,6 +23,7 @@ import java.text.DecimalFormat;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventInitializationChanged;
import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
@ -84,15 +85,17 @@ public class LocalProfileFragment extends SubscriberFragment {
}
};
PumpDescription pumpDescription = ConfigBuilderPlugin.getActivePump().getPumpDescription();
View layout = inflater.inflate(R.layout.localprofile_fragment, container, false);
diaView = (NumberPicker) layout.findViewById(R.id.localprofile_dia);
diaView.setParams(localProfilePlugin.dia, 2d, 48d, 0.1d, new DecimalFormat("0.0"), false, textWatch);
mgdlView = (RadioButton) layout.findViewById(R.id.localprofile_mgdl);
mmolView = (RadioButton) layout.findViewById(R.id.localprofile_mmol);
icView = new TimeListEdit(getContext(), layout, R.id.localprofile_ic, MainApp.sResources.getString(R.string.nsprofileview_ic_label) + ":", getPlugin().ic, null, 0.1d, new DecimalFormat("0.0"), save);
isfView = new TimeListEdit(getContext(), layout, R.id.localprofile_isf, MainApp.sResources.getString(R.string.nsprofileview_isf_label) + ":", getPlugin().isf, null, 0.1d, new DecimalFormat("0.0"), save);
basalView = new TimeListEdit(getContext(), layout, R.id.localprofile_basal, MainApp.sResources.getString(R.string.nsprofileview_basal_label) + ": " + getSumLabel(), getPlugin().basal, null, 0.01d, new DecimalFormat("0.00"), save);
targetView = new TimeListEdit(getContext(), layout, R.id.localprofile_target, MainApp.sResources.getString(R.string.nsprofileview_target_label) + ":", getPlugin().targetLow, getPlugin().targetHigh, 0.1d, new DecimalFormat("0.0"), save);
icView = new TimeListEdit(getContext(), layout, R.id.localprofile_ic, MainApp.sResources.getString(R.string.nsprofileview_ic_label) + ":", getPlugin().ic, null, 0.5, 50d, 0.1d, new DecimalFormat("0.0"), save);
isfView = new TimeListEdit(getContext(), layout, R.id.localprofile_isf, MainApp.sResources.getString(R.string.nsprofileview_isf_label) + ":", getPlugin().isf, null, 0.5, 500d, 0.1d, new DecimalFormat("0.0"), save);
basalView = new TimeListEdit(getContext(), layout, R.id.localprofile_basal, MainApp.sResources.getString(R.string.nsprofileview_basal_label) + ": " + getSumLabel(), getPlugin().basal, null, pumpDescription.basalMinimumRate, 10, 0.01d, new DecimalFormat("0.00"), save);
targetView = new TimeListEdit(getContext(), layout, R.id.localprofile_target, MainApp.sResources.getString(R.string.nsprofileview_target_label) + ":", getPlugin().targetLow, getPlugin().targetHigh, 3d, 200, 0.1d, new DecimalFormat("0.0"), save);
profileswitchButton = (Button) layout.findViewById(R.id.localprofile_profileswitch);
if (!ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable) {

View file

@ -4,6 +4,7 @@ package info.nightscout.androidaps.plugins.PumpCombo;
import android.app.Activity;
import android.app.AlertDialog;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle;
import android.text.Spanned;
import android.view.LayoutInflater;
@ -137,11 +138,14 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
if (ps.insulinState == PumpState.EMPTY || ps.batteryState == PumpState.EMPTY
|| ps.activeAlert != null && ps.activeAlert.errorCode != null) {
stateView.setTextColor(Color.RED);
stateView.setTypeface(null, Typeface.BOLD);
} else if (plugin.getPump().state.suspended
|| ps.activeAlert != null && ps.activeAlert.warningCode != null) {
stateView.setTextColor(Color.YELLOW);
stateView.setTypeface(null, Typeface.BOLD);
} else {
stateView.setTextColor(Color.WHITE);
stateView.setTypeface(null, Typeface.NORMAL);
}
// activity
@ -171,12 +175,15 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
if (ps.insulinState == PumpState.LOW) {
reservoirView.setTextColor(Color.YELLOW);
reservoirView.setText(R.string.combo_reservoir_low);
reservoirView.setTypeface(null, Typeface.BOLD);
} else if (ps.insulinState == PumpState.EMPTY) {
reservoirView.setTextColor(Color.RED);
reservoirView.setText(R.string.combo_reservoir_empty);
reservoirView.setTypeface(null, Typeface.BOLD);
} else {
reservoirView.setTextColor(Color.WHITE);
reservoirView.setText(R.string.combo_reservoir_normal);
reservoirView.setTypeface(null, Typeface.NORMAL);
}
// last connection

View file

@ -82,7 +82,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
pumpDescription.isSetBasalProfileCapable = true;
pumpDescription.basalStep = 0.01d;
pumpDescription.basalMinimumRate = 0.0d;
pumpDescription.basalMinimumRate = 0.05d;
pumpDescription.isRefillingCapable = true;
}
@ -577,9 +577,18 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
return setTempBasalPercent(roundedPercentage, durationInMinutes);
}
// Note: AAPS calls this directly only for setting a temp basal issued by the user
/**
* Note: AAPS calls this directly only for setting a temp basal issued by the user
*
* @param forceNew Driver always applies the requested TBR and simply overrides whatever TBR
* is or isn't running at the moment
*/
@Override
public PumpEnactResult setTempBasalPercent(Integer percent, final Integer durationInMinutes) {
public PumpEnactResult setTempBasalPercent(Integer percent, final Integer durationInMinutes, boolean forceNew) {
return setTempBasalPercent(percent, durationInMinutes);
}
private PumpEnactResult setTempBasalPercent(Integer percent, final Integer durationInMinutes) {
log.debug("setTempBasalPercent called with " + percent + "% for " + durationInMinutes + "min");
int adjustedPercent = percent;

View file

@ -434,7 +434,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
// Convert duration from minutes to hours
if (Config.logPumpActions)
log.debug("setTempBasalAbsolute: Setting temp basal " + percentRate + "% for " + durationInMinutes + " mins (doLowTemp || doHighTemp)");
return setTempBasalPercent(percentRate, durationInMinutes);
return setTempBasalPercent(percentRate, durationInMinutes, false);
}
if (doExtendedTemp) {
// Check if some temp is already in progress
@ -499,7 +499,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
}
@Override
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes) {
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, boolean enforceNew) {
PumpEnactResult result = new PumpEnactResult();
ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder();
percent = configBuilderPlugin.applyBasalConstraints(percent);
@ -514,7 +514,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
if (percent > getPumpDescription().maxTempPercent)
percent = getPumpDescription().maxTempPercent;
TemporaryBasal runningTB = MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis());
if (runningTB != null && runningTB.percentRate == percent) {
if (runningTB != null && runningTB.percentRate == percent && !enforceNew) {
result.enacted = false;
result.success = true;
result.isTempCancel = false;

View file

@ -436,7 +436,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
// Convert duration from minutes to hours
if (Config.logPumpActions)
log.debug("setTempBasalAbsolute: Setting temp basal " + percentRate + "% for " + durationInMinutes + " mins (doLowTemp || doHighTemp)");
return setTempBasalPercent(percentRate, durationInMinutes);
return setTempBasalPercent(percentRate, durationInMinutes, false);
}
if (doExtendedTemp) {
// Check if some temp is already in progress
@ -501,7 +501,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
}
@Override
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes) {
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, boolean enforceNew) {
PumpEnactResult result = new PumpEnactResult();
ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder();
percent = configBuilderPlugin.applyBasalConstraints(percent);
@ -516,7 +516,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
if (percent > getPumpDescription().maxTempPercent)
percent = getPumpDescription().maxTempPercent;
TemporaryBasal runningTB = MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis());
if (runningTB != null && runningTB.percentRate == percent) {
if (runningTB != null && runningTB.percentRate == percent && enforceNew) {
result.enacted = false;
result.success = true;
result.isTempCancel = false;

View file

@ -580,7 +580,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
}
@Override
public synchronized PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes) {
public synchronized PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, boolean enforceNew) {
PumpEnactResult result = new PumpEnactResult();
ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder();
percent = configBuilderPlugin.applyBasalConstraints(percent);
@ -595,7 +595,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
if (percent > getPumpDescription().maxTempPercent)
percent = getPumpDescription().maxTempPercent;
TemporaryBasal runningTB = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
if (runningTB != null && runningTB.percentRate == percent) {
if (runningTB != null && runningTB.percentRate == percent && !enforceNew) {
result.enacted = false;
result.success = true;
result.isTempCancel = false;

View file

@ -118,7 +118,7 @@ public class PairingProgressDialog extends DialogFragment implements View.OnClic
@Override
public void dismiss() {
super.dismiss();
super.dismissAllowingStateLoss();
if (helperActivity != null) {
helperActivity.finish();
}

View file

@ -185,7 +185,10 @@ public class DanaRSService extends Service {
while (!msg.done && bleComm.isConnected()) {
SystemClock.sleep(100);
}
lastHistoryFetched = DanaRS_Packet_APS_History_Events.lastEventTimeLoaded - 45 * 60 * 1000L; // always load last 45 min
if (DanaRS_Packet_APS_History_Events.lastEventTimeLoaded != 0)
lastHistoryFetched = DanaRS_Packet_APS_History_Events.lastEventTimeLoaded - 45 * 60 * 1000L; // always load last 45 min
else
lastHistoryFetched = 0;
log.debug("Events loaded");
return new PumpEnactResult().success(true);
}

View file

@ -437,7 +437,7 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
}
@Override
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes) {
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, boolean enforceNew) {
PumpEnactResult result = new PumpEnactResult();
ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder();
percent = configBuilderPlugin.applyBasalConstraints(percent);
@ -452,7 +452,7 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
if (percent > getPumpDescription().maxTempPercent)
percent = getPumpDescription().maxTempPercent;
TemporaryBasal runningTB = MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis());
if (runningTB != null && runningTB.percentRate == percent) {
if (runningTB != null && runningTB.percentRate == percent && !enforceNew) {
result.enacted = false;
result.success = true;
result.isTempCancel = false;

View file

@ -527,7 +527,10 @@ public class DanaRv2ExecutionService extends Service {
waitMsec(100);
}
waitMsec(200);
lastHistoryFetched = MsgHistoryEvents_v2.lastEventTimeLoaded - 45 * 60 * 1000L; //always load last 45 min;
if (MsgHistoryEvents_v2.lastEventTimeLoaded != 0)
lastHistoryFetched = MsgHistoryEvents_v2.lastEventTimeLoaded - 45 * 60 * 1000L; //always load last 45 min;
else
lastHistoryFetched = 0;
return new PumpEnactResult().success(true);
}

View file

@ -204,7 +204,7 @@ public class MDIPlugin implements PluginBase, PumpInterface {
}
@Override
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes) {
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, boolean enforceNew) {
PumpEnactResult result = new PumpEnactResult();
result.success = false;
result.comment = MainApp.instance().getString(R.string.pumperror);

View file

@ -304,7 +304,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
}
@Override
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes) {
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, boolean enforceNew) {
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
PumpEnactResult result = new PumpEnactResult();
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {

View file

@ -215,6 +215,8 @@ public class WearPlugin implements PluginBase {
@Subscribe
public void onStatusEvent(final EventDismissBolusprogressIfRunning ev) {
if(ev.result == null) return;
String status;
if(ev.result.success){
status = MainApp.sResources.getString(R.string.success);

View file

@ -203,7 +203,7 @@ public class CommandQueue {
}
// returns true if command is queued
public boolean tempBasalPercent(int percent, int durationInMinutes, Callback callback) {
public boolean tempBasalPercent(int percent, int durationInMinutes, boolean enforceNew, Callback callback) {
if (isRunning(Command.CommandType.TEMPBASAL)) {
if (callback != null)
callback.result(executingNowError()).run();
@ -216,7 +216,7 @@ public class CommandQueue {
Integer percentAfterConstraints = MainApp.getConfigBuilder().applyBasalConstraints(percent);
// add new command to queue
add(new CommandTempBasalPercent(percentAfterConstraints, durationInMinutes, callback));
add(new CommandTempBasalPercent(percentAfterConstraints, durationInMinutes, enforceNew, callback));
notifyAboutNewCommand();
@ -326,14 +326,14 @@ public class CommandQueue {
// returns true if command is queued
public boolean readStatus(String reason, Callback callback) {
if (isRunning(Command.CommandType.READSTATUS)) {
if (callback != null)
callback.result(executingNowError()).run();
return false;
}
//if (isRunning(Command.CommandType.READSTATUS)) {
// if (callback != null)
// callback.result(executingNowError()).run();
// return false;
//}
// remove all unfinished
removeAll(Command.CommandType.READSTATUS);
//removeAll(Command.CommandType.READSTATUS);
// add new command to queue
add(new CommandReadStatus(reason, callback));

View file

@ -59,7 +59,7 @@ public class QueueThread extends Thread {
}
if (!pump.isConnected() && secondsElapsed > Constants.PUMP_MAX_CONNECTION_TIME_IN_SECONDS) {
MainApp.bus().post(new EventDismissBolusprogressIfRunning(new PumpEnactResult()));
MainApp.bus().post(new EventDismissBolusprogressIfRunning(null));
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.connectiontimedout)));
log.debug("QUEUE: timed out");
pump.stopConnecting();
@ -79,7 +79,7 @@ public class QueueThread extends Thread {
mBluetoothAdapter.enable();
SystemClock.sleep(1000);
//start over again once after watchdog barked
connectionStartTime = System.currentTimeMillis();
connectionStartTime = lastCommandTime = System.currentTimeMillis();
} else {
queue.clear();
return;

View file

@ -18,17 +18,19 @@ public class CommandTempBasalPercent extends Command {
int durationInMinutes;
int percent;
boolean enforceNew;
public CommandTempBasalPercent(int percent, int durationInMinutes, Callback callback) {
public CommandTempBasalPercent(int percent, int durationInMinutes, boolean enforceNew, Callback callback) {
commandType = CommandType.TEMPBASAL;
this.percent = percent;
this.durationInMinutes = durationInMinutes;
this.enforceNew = enforceNew;
this.callback = callback;
}
@Override
public void execute() {
PumpEnactResult r = ConfigBuilderPlugin.getActivePump().setTempBasalPercent(percent, durationInMinutes);
PumpEnactResult r = ConfigBuilderPlugin.getActivePump().setTempBasalPercent(percent, durationInMinutes, enforceNew);
if (Config.logCongigBuilderActions)
log.debug("setTempBasalPercent percent: " + percent + " durationInMinutes: " + durationInMinutes + " success: " + r.success + " enacted: " + r.enacted);
if (callback != null)

View file

@ -71,7 +71,9 @@ public class BolusWizard {
targetBGLow = Profile.fromMgdlToUnits(tempTarget.low, specificProfile.getUnits());
targetBGHigh = Profile.fromMgdlToUnits(tempTarget.high, specificProfile.getUnits());
}
if (bg <= targetBGLow) {
if (bg >= targetBGLow && bg <= targetBGHigh) {
bgDiff = 0d;
} else if (bg <= targetBGLow) {
bgDiff = bg - targetBGLow;
} else {
bgDiff = bg - targetBGHigh;

View file

@ -2,10 +2,12 @@ package info.nightscout.utils;
import android.support.v4.util.LongSparseArray;
import android.text.format.DateUtils;
import android.util.SparseIntArray;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.format.ISODateTimeFormat;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
@ -27,9 +29,7 @@ public class DateUtil {
/**
* The date format in iso.
*/
private static String FORMAT_DATE_ISO = "yyyy-MM-dd'T'HH:mm:ssZ";
private static String FORMAT_DATE_ISO_MSEC = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";
private static String FORMAT_DATE_ISO_MSEC_UTC = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
private static String FORMAT_DATE_ISO_OUT = "yyyy-MM-dd'T'HH:mm:ss'Z'";
/**
* Takes in an ISO date string of the following format:
@ -41,33 +41,10 @@ public class DateUtil {
*/
public static Date fromISODateString(String isoDateString)
throws Exception {
SimpleDateFormat f = new SimpleDateFormat(FORMAT_DATE_ISO, Locale.getDefault());
Date date;
f.setTimeZone(TimeZone.getTimeZone("UTC"));
try {
date = f.parse(isoDateString);
return date;
} catch (ParseException e) {
}
f = new SimpleDateFormat(FORMAT_DATE_ISO_MSEC, Locale.getDefault());
f.setTimeZone(TimeZone.getTimeZone("UTC"));
try {
date = f.parse(isoDateString);
return date;
} catch (ParseException e) {
}
f = new SimpleDateFormat(FORMAT_DATE_ISO_MSEC_UTC, Locale.getDefault());
f.setTimeZone(TimeZone.getTimeZone("UTC"));
try {
date = f.parse(isoDateString);
return date;
} catch (ParseException e) {
}
throw new ParseException("Unparseable date: " + isoDateString, 0);
DateTimeFormatter parser = ISODateTimeFormat.dateTimeParser();
DateTime dateTime = DateTime.parse(isoDateString, parser);
return dateTime.toDate();
}
/**
@ -79,7 +56,7 @@ public class DateUtil {
* @return the iso-formatted date string
*/
public static String toISOString(Date date, String format, TimeZone tz) {
if (format == null) format = FORMAT_DATE_ISO;
if (format == null) format = FORMAT_DATE_ISO_OUT;
if (tz == null) tz = TimeZone.getDefault();
DateFormat f = new SimpleDateFormat(format, Locale.getDefault());
f.setTimeZone(tz);
@ -87,21 +64,18 @@ public class DateUtil {
}
public static String toISOString(Date date) {
return toISOString(date, FORMAT_DATE_ISO, TimeZone.getTimeZone("UTC"));
return toISOString(date, FORMAT_DATE_ISO_OUT, TimeZone.getTimeZone("UTC"));
}
public static String toISOString(long date) {
return toISOString(new Date(date), FORMAT_DATE_ISO, TimeZone.getTimeZone("UTC"));
return toISOString(new Date(date), FORMAT_DATE_ISO_OUT, TimeZone.getTimeZone("UTC"));
}
public static Date toDate(Integer seconds) {
Calendar calendar = new GregorianCalendar();
calendar.set(Calendar.HOUR_OF_DAY, seconds / 60 / 60);
String a = calendar.getTime().toString();
calendar.set(Calendar.MINUTE, (seconds / 60) % 60);
String b = calendar.getTime().toString();
calendar.set(Calendar.SECOND, 0);
String c = calendar.getTime().toString();
return calendar.getTime();
}

View file

@ -0,0 +1,21 @@
package info.nightscout.utils;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Created by mike on 22.12.2017.
*/
public class PercentageSplitter {
public static String pureName(String name) {
String newName = name;
String s = "(.*)\\((\\d+)\\%\\)";
Pattern r = Pattern.compile(s);
Matcher m = r.matcher(name);
if (m.find()) {
newName = m.group(1);
}
return newName;
}
}

View file

@ -0,0 +1,67 @@
package info.nightscout.utils;
import android.app.Activity;
import android.content.Context;
import android.os.SystemClock;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Created by mike on 22.12.2017.
*/
public class SingleClickButton extends android.support.v7.widget.AppCompatButton implements View.OnClickListener {
private static Logger log = LoggerFactory.getLogger(SingleClickButton.class);
Context context;
OnClickListener listener = null;
public SingleClickButton(Context context) {
super(context);
this.context = context;
super.setOnClickListener(this);
}
public SingleClickButton(Context context, AttributeSet attrs) {
super(context, attrs);
this.context = context;
super.setOnClickListener(this);
}
public SingleClickButton(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
this.context = context;
super.setOnClickListener(this);
}
@Override
public void setOnClickListener(@Nullable OnClickListener l) {
listener = l;
}
@Override
public void onClick(final View v) {
setEnabled(false);
new Thread(new Runnable() {
@Override
public void run() {
SystemClock.sleep(3000);
Activity activity = (Activity) context;
if (activity != null)
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
setEnabled(true);
log.debug("Button enabled");
}
});
}
}).start();
if (listener != null)
listener.onClick(v);
}
}

View file

@ -52,6 +52,8 @@ public class TimeListEdit {
private JSONArray data1;
private JSONArray data2;
private double step;
private double min;
private double max;
private NumberFormat formatter;
private Runnable save;
private LinearLayout layout;
@ -59,7 +61,7 @@ public class TimeListEdit {
private int inflatedUntil = -1;
public TimeListEdit(Context context, View view, int resLayoutId, String label, JSONArray data1, JSONArray data2, double step, NumberFormat formatter, Runnable save) {
public TimeListEdit(Context context, View view, int resLayoutId, String label, JSONArray data1, JSONArray data2, double min, double max, double step, NumberFormat formatter, Runnable save) {
this.context = context;
this.view = view;
this.resLayoutId = resLayoutId;
@ -67,6 +69,8 @@ public class TimeListEdit {
this.data1 = data1;
this.data2 = data2;
this.step = step;
this.min = min;
this.max = max;
this.formatter = formatter;
this.save = save;
buildView();
@ -239,8 +243,8 @@ public class TimeListEdit {
if (i == 0) next = ONEHOURINSECONDS;
fillSpinner(timeSpinner, secondFromMidnight(i), previous, next);
editText1.setParams(value1(i), 0.1d, 100d, step, formatter, false);
editText2.setParams(value2(i), 0.1d, 100d, step, formatter, false);
editText1.setParams(value1(i), min, max, step, formatter, false);
editText2.setParams(value2(i), min, max, step, formatter, false);
if (data2 == null) {
editText2.setVisibility(View.GONE);

View file

@ -13,7 +13,7 @@
android:layout_height="wrap_content"
android:orientation="vertical">
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/actions_profileswitch"
style="?android:attr/buttonStyle"
android:layout_width="fill_parent"
@ -26,7 +26,7 @@
android:drawableTop="@drawable/icon_actions_profileswitch"
android:text="@string/careportal_profileswitch" />
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/actions_temptarget"
style="?android:attr/buttonStyle"
android:layout_width="fill_parent"
@ -39,7 +39,7 @@
android:drawableTop="@drawable/icon_actions_temptarget"
android:text="@string/careportal_temporarytarget" />
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/actions_settempbasal"
style="?android:attr/buttonStyle"
android:layout_width="fill_parent"
@ -52,7 +52,7 @@
android:drawableTop="@drawable/icon_actions_starttempbasal"
android:text="@string/overview_tempbasal_button" />
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/actions_canceltempbasal"
style="?android:attr/buttonStyle"
android:layout_width="fill_parent"
@ -65,7 +65,7 @@
android:drawableTop="@drawable/icon_cancelbasal"
android:text="Cancel temp basal" />
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/actions_extendedbolus"
style="?android:attr/buttonStyle"
android:layout_width="fill_parent"
@ -78,7 +78,7 @@
android:drawableTop="@drawable/icon_actions_startextbolus"
android:text="@string/overview_extendedbolus_button" />
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/actions_extendedbolus_cancel"
style="?android:attr/buttonStyle"
android:layout_width="fill_parent"
@ -91,7 +91,7 @@
android:drawableTop="@drawable/icon_actions_cancelextbolus"
android:text="@string/overview_extendedbolus_cancel_button" />
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/actions_fill"
style="?android:attr/buttonStyle"
android:layout_width="fill_parent"

View file

@ -51,7 +51,7 @@
android:padding="10dip"
app:columnCount="3">
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/careportal_bgcheck"
style="@style/ButtonSmallFontStyle"
android:layout_width="0px"
@ -66,7 +66,7 @@
app:layout_gravity="fill"
app:layout_row="0" />
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/careportal_exercise"
style="@style/ButtonSmallFontStyle"
android:layout_width="0dp"
@ -80,7 +80,7 @@
app:layout_gravity="fill"
app:layout_row="0" />
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/careportal_temporarytarget"
style="@style/ButtonSmallFontStyle"
android:layout_width="0dp"
@ -111,7 +111,7 @@
android:padding="10dip"
app:columnCount="3">
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/careportal_snackbolus"
style="@style/ButtonSmallFontStyle"
android:layout_width="0dp"
@ -125,7 +125,7 @@
app:layout_gravity="fill"
app:layout_row="1" />
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/careportal_mealbolus"
style="@style/ButtonSmallFontStyle"
android:layout_width="0dp"
@ -139,7 +139,7 @@
app:layout_gravity="fill"
app:layout_row="1" />
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/careportal_correctionbolus"
style="@style/ButtonSmallFontStyle"
android:layout_width="0dp"
@ -153,7 +153,7 @@
app:layout_gravity="fill"
app:layout_row="1" />
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/careportal_carbscorrection"
style="@style/ButtonSmallFontStyle"
android:layout_width="0dp"
@ -167,7 +167,7 @@
app:layout_gravity="fill"
app:layout_row="2" />
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/careportal_combobolus"
style="@style/ButtonSmallFontStyle"
android:layout_width="0dp"
@ -181,7 +181,7 @@
app:layout_gravity="fill"
app:layout_row="2" />
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/careportal_tempbasalstart"
style="@style/ButtonSmallFontStyle"
android:layout_width="0dp"
@ -195,7 +195,7 @@
app:layout_gravity="fill"
app:layout_row="2" />
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/careportal_tempbasalend"
style="@style/ButtonSmallFontStyle"
android:layout_width="0dp"
@ -225,7 +225,7 @@
android:padding="10dip"
app:columnCount="3">
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/careportal_cgmsensorstart"
style="@style/ButtonSmallFontStyle"
android:layout_width="0dp"
@ -240,7 +240,7 @@
app:layout_row="1" />
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/careportal_cgmsensorinsert"
style="@style/ButtonSmallFontStyle"
android:layout_width="0dp"
@ -255,7 +255,7 @@
app:layout_row="1" />
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/careportal_openapsoffline"
style="@style/ButtonSmallFontStyle"
android:layout_width="0dp"
@ -270,7 +270,7 @@
app:layout_row="1" />
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/careportal_announcement"
style="@style/ButtonSmallFontStyle"
android:layout_width="0dp"
@ -284,7 +284,7 @@
app:layout_gravity="fill"
app:layout_row="4" />
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/careportal_question"
style="@style/ButtonSmallFontStyle"
android:layout_width="0dp"
@ -298,7 +298,7 @@
app:layout_gravity="fill"
app:layout_row="4" />
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/careportal_note"
style="@style/ButtonSmallFontStyle"
android:layout_width="0dp"
@ -328,7 +328,7 @@
android:padding="10dip"
app:columnCount="3">
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/careportal_pumpsitechange"
style="@style/ButtonSmallFontStyle"
android:layout_width="0dp"
@ -342,7 +342,7 @@
app:layout_gravity="fill"
app:layout_row="0" />
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/careportal_insulincartridgechange"
style="@style/ButtonSmallFontStyle"
android:layout_width="0dp"
@ -356,7 +356,7 @@
app:layout_gravity="fill"
app:layout_row="0" />
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/careportal_profileswitch"
style="@style/ButtonSmallFontStyle"
android:layout_width="0dp"
@ -371,7 +371,7 @@
app:layout_row="0" />
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/careportal_pumpbatterychange"
style="@style/ButtonSmallFontStyle"
android:layout_width="0dp"

View file

@ -402,7 +402,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableTop="@drawable/icon_bolus"
android:drawableTop="@drawable/icon_danarhistory"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:visibility="gone"

View file

@ -381,7 +381,7 @@
android:orientation="horizontal"
android:visibility="gone">
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/overview_accepttempbutton"
style="?android:attr/buttonStyle"
android:layout_width="match_parent"
@ -398,7 +398,7 @@
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/overview_treatmentbutton"
style="?android:attr/buttonStyle"
android:layout_width="0px"
@ -413,7 +413,7 @@
android:textSize="10sp"
android:visibility="gone" />
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/overview_wizardbutton"
style="?android:attr/buttonStyle"
android:layout_width="0px"
@ -428,7 +428,7 @@
android:textSize="10sp"
android:visibility="gone" />
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/overview_calibrationbutton"
style="?android:attr/buttonStyle"
android:layout_width="0px"
@ -443,7 +443,7 @@
android:textSize="10sp"
android:visibility="gone" />
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/overview_quickwizardbutton"
style="?android:attr/buttonStyle"
android:layout_width="0px"

View file

@ -593,7 +593,7 @@
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/overview_treatmentbutton"
style="?android:attr/buttonStyle"
android:layout_width="0px"
@ -607,7 +607,7 @@
android:textColor="@color/colorTreatmentButton"
android:textSize="10sp" />
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/overview_wizardbutton"
style="?android:attr/buttonStyle"
android:layout_width="0px"
@ -622,7 +622,7 @@
android:textSize="10sp"
android:visibility="gone" />
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/overview_quickwizardbutton"
style="?android:attr/buttonStyle"
android:layout_width="0px"

View file

@ -691,7 +691,7 @@
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/overview_treatmentbutton"
style="?android:attr/buttonStyle"
android:layout_width="0px"
@ -705,7 +705,7 @@
android:textColor="@color/colorTreatmentButton"
android:textSize="10sp" />
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/overview_wizardbutton"
style="?android:attr/buttonStyle"
android:layout_width="0px"
@ -720,7 +720,7 @@
android:textSize="10sp"
android:visibility="gone" />
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/overview_calibrationbutton"
style="?android:attr/buttonStyle"
android:layout_width="0px"
@ -735,7 +735,7 @@
android:textSize="10sp"
android:visibility="gone" />
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/overview_quickwizardbutton"
style="?android:attr/buttonStyle"
android:layout_width="0px"

View file

@ -360,7 +360,7 @@
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/overview_accepttempbutton"
style="?android:attr/buttonStyle"
android:layout_width="fill_parent"
@ -377,7 +377,7 @@
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/overview_treatmentbutton"
style="?android:attr/buttonStyle"
android:layout_width="0px"
@ -391,7 +391,7 @@
android:textColor="@color/colorTreatmentButton"
android:textSize="10sp" />
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/overview_wizardbutton"
style="?android:attr/buttonStyle"
android:layout_width="0px"
@ -406,7 +406,7 @@
android:textSize="10sp"
android:visibility="gone" />
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/overview_calibrationbutton"
style="?android:attr/buttonStyle"
android:layout_width="0px"
@ -421,7 +421,7 @@
android:textSize="10sp"
android:visibility="gone" />
<Button
<info.nightscout.utils.SingleClickButton
android:id="@+id/overview_quickwizardbutton"
style="?android:attr/buttonStyle"
android:layout_width="0px"

View file

@ -8,6 +8,14 @@
android:orientation="vertical"
android:padding="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:paddingBottom="10dp"
android:text="@string/virtualpump_extendedbolus_label"
android:textAppearance="?android:attr/textAppearanceLarge" />
<LinearLayout
android:id="@+id/careportal_newnstreatment_insulin_layout"
android:layout_width="match_parent"

View file

@ -674,4 +674,4 @@
<string name="localalertsettings_title">Τοπικές Ειδοποιήσεις</string>
<string name="enable_missed_bg_readings_alert">Ειδοποίησε αν δεν ληφθούν δεδομένα μετρήσεων BG</string>
<string name="btwatchdog_summary">Απενεργοποιεί το bluetooth του τηλεφώνου για ένα δευτερόλεπτο αν δεν είναι δυνατή η σύνδεση με την αντλία.Αυτό μπορεί να βοηθήσει σε ορισμένα τηλέφωνα όπου το bluetooth παγώνει</string>
</resources>
</resources>

View file

@ -791,6 +791,7 @@
<string name="key_dexcomg5_xdripupload" translatable="false">dexcomg5_xdripupload</string>
<string name="dexcomg5_xdripupload_summary">In xDrip+ select 640g/Eversense data source</string>
<string name="nsclientbg">NSClient BG</string>
<string name="minimalbasalvaluereplaced">Basal value replaced by minimal supported value</string>
<string name="bolusstopping">Stopping bolus delivery</string>
<string name="bolusstopped">Bolus delivery stopped</string>
<string name="combo_programming_bolus">Programming pump for bolusing</string>

View file

@ -3,7 +3,9 @@ package info.nightscout.utils;
import org.junit.Test;
import static org.junit.Assert.*;
import java.util.Date;
import static org.junit.Assert.assertEquals;
/**
* Created by mike on 20.11.2017.
@ -17,10 +19,15 @@ public class DateUtilTest {
@Test
public void fromISODateStringTest() throws Exception {
assertEquals( 1511124634417L, DateUtil.fromISODateString("2017-11-19T22:50:34.417+0200").getTime());
assertEquals( 1511124634000L, DateUtil.fromISODateString("2017-11-19T22:50:34+0200").getTime());
assertEquals( 1512317365000L, DateUtil.fromISODateString("2017-12-03T16:09:25.000Z").getTime());
assertEquals(1511124634417L, DateUtil.fromISODateString("2017-11-19T22:50:34.417+0200").getTime());
assertEquals(1511124634000L, DateUtil.fromISODateString("2017-11-19T22:50:34+0200").getTime());
assertEquals(1512317365000L, DateUtil.fromISODateString("2017-12-03T16:09:25.000Z").getTime());
assertEquals(1513902750000L, DateUtil.fromISODateString("2017-12-22T00:32:30Z").getTime());
}
@Test
public void toISOStringTest() throws Exception {
assertEquals("2017-12-22T00:32:30Z", DateUtil.toISOString(new Date(1513902750000L)));
}
}

View file

@ -0,0 +1,20 @@
package info.nightscout.utils;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* Created by mike on 22.12.2017.
*/
public class PercentageSplitterTest {
public PercentageSplitterTest() {
super();
}
@Test
public void pureNameTest() throws Exception {
assertEquals("Fiasp", PercentageSplitter.pureName("Fiasp(101%)"));
}
}