Merge branch 'dev' into dev

This commit is contained in:
Milos Kozak 2017-02-09 17:01:05 +01:00 committed by GitHub
commit 8a2846c516
13 changed files with 61 additions and 38 deletions

View file

@ -219,7 +219,7 @@ public class DanaRFragment extends Fragment implements FragmentBase {
Long agoMsec = new Date().getTime() - pump.lastBolusTime.getTime(); Long agoMsec = new Date().getTime() - pump.lastBolusTime.getTime();
double agoHours = agoMsec / 60d / 60d / 1000d; double agoHours = agoMsec / 60d / 60d / 1000d;
if (agoHours < 6) // max 6h back if (agoHours < 6) // max 6h back
lastBolusView.setText(DateUtil.timeString(pump.lastBolusTime) + " (" + DecimalFormatter.to1Decimal(agoHours) + " " + getString(R.string.hoursago) + ") " + DecimalFormatter.to2Decimal(getPlugin().getDanaRPump().lastBolusAmount) + " U"); lastBolusView.setText(DateUtil.timeString(pump.lastBolusTime) + " (" + DecimalFormatter.to1Decimal(agoHours) + " " + MainApp.sResources.getString(R.string.hoursago) + ") " + DecimalFormatter.to2Decimal(getPlugin().getDanaRPump().lastBolusAmount) + " U");
else lastBolusView.setText(""); else lastBolusView.setText("");
} }
@ -242,7 +242,7 @@ public class DanaRFragment extends Fragment implements FragmentBase {
SetWarnColor.setColorInverse(batteryView, pump.batteryRemaining, 51d, 26d); SetWarnColor.setColorInverse(batteryView, pump.batteryRemaining, 51d, 26d);
iobView.setText(pump.iob + " U"); iobView.setText(pump.iob + " U");
if (pump.isNewPump) { if (pump.isNewPump) {
firmwareView.setText(String.format(getString(R.string.danar_model), pump.model, pump.protocol, pump.productCode)); firmwareView.setText(String.format(MainApp.sResources.getString(R.string.danar_model), pump.model, pump.protocol, pump.productCode));
} else { } else {
firmwareView.setText("OLD"); firmwareView.setText("OLD");
} }

View file

@ -258,6 +258,8 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
if (!isInitialized()) if (!isInitialized())
return true; // TODO: not sure what's better. so far TRUE to prevent too many SMS return true; // TODO: not sure what's better. so far TRUE to prevent too many SMS
DanaRPump pump = getDanaRPump(); DanaRPump pump = getDanaRPump();
if (pump.pumpProfiles == null)
return true; // TODO: not sure what's better. so far TRUE to prevent too many SMS
int basalValues = pump.basal48Enable ? 48 : 24; int basalValues = pump.basal48Enable ? 48 : 24;
int basalIncrement = pump.basal48Enable ? 30 * 60 : 60 * 60; int basalIncrement = pump.basal48Enable ? 30 * 60 : 60 * 60;
for (int h = 0; h < basalValues; h++) { for (int h = 0; h < basalValues; h++) {
@ -290,17 +292,19 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
@Override @Override
public double getTempBasalAbsoluteRate() { public double getTempBasalAbsoluteRate() {
if (isRealTempBasalInProgress()) { TempBasal tb = getRealTempBasal();
if (getRealTempBasal().isAbsolute) { if (tb != null) {
return getRealTempBasal().absolute; if (tb.isAbsolute) {
return tb.absolute;
} else { } else {
Double baseRate = getBaseBasalRate(); Double baseRate = getBaseBasalRate();
Double tempRate = baseRate * (getRealTempBasal().percent / 100d); Double tempRate = baseRate * (tb.percent / 100d);
return tempRate; return tempRate;
} }
} }
if (isExtendedBoluslInProgress() && useExtendedBoluses) { TempBasal eb = getExtendedBolus();
return getBaseBasalRate() + getExtendedBolus().absolute; if (eb != null && useExtendedBoluses) {
return getBaseBasalRate() + eb.absolute;
} }
return 0; return 0;
} }
@ -707,11 +711,12 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
extended.put("PumpIOB", getDanaRPump().iob); extended.put("PumpIOB", getDanaRPump().iob);
extended.put("LastBolus", getDanaRPump().lastBolusTime.toLocaleString()); extended.put("LastBolus", getDanaRPump().lastBolusTime.toLocaleString());
extended.put("LastBolusAmount", getDanaRPump().lastBolusAmount); extended.put("LastBolusAmount", getDanaRPump().lastBolusAmount);
if (isTempBasalInProgress()) { TempBasal tb = getTempBasal();
if (tb != null) {
extended.put("TempBasalAbsoluteRate", getTempBasalAbsoluteRate()); extended.put("TempBasalAbsoluteRate", getTempBasalAbsoluteRate());
extended.put("TempBasalStart", getTempBasal().timeStart.toLocaleString()); extended.put("TempBasalStart", tb.timeStart.toLocaleString());
extended.put("TempBasalRemaining", getTempBasal().getPlannedRemainingMinutes()); extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes());
extended.put("IsExtended", getTempBasal().isExtended); extended.put("IsExtended", tb.isExtended);
} }
extended.put("BaseBasalRate", getBaseBasalRate()); extended.put("BaseBasalRate", getBaseBasalRate());
try { try {

View file

@ -56,6 +56,7 @@ import info.nightscout.androidaps.plugins.DanaR.comm.RecordTypes;
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRConnectionStatus; import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRConnectionStatus;
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRSyncStatus; import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRSyncStatus;
import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.SafeParse;
import info.nightscout.utils.ToastUtils; import info.nightscout.utils.ToastUtils;
public class DanaRStatsActivity extends Activity { public class DanaRStatsActivity extends Activity {
@ -366,7 +367,7 @@ public class DanaRStatsActivity extends Activity {
return; return;
} }
else { else {
magicNumber = Double.parseDouble(TBB); magicNumber = SafeParse.stringToDouble(TBB);
} }
magicNumber *=2; magicNumber *=2;

View file

@ -240,7 +240,7 @@ public class DanaRKoreanFragment extends Fragment implements FragmentBase {
SetWarnColor.setColorInverse(batteryView, pump.batteryRemaining, 51d, 26d); SetWarnColor.setColorInverse(batteryView, pump.batteryRemaining, 51d, 26d);
iobView.setText(pump.iob + " U"); iobView.setText(pump.iob + " U");
if (pump.isNewPump) { if (pump.isNewPump) {
firmwareView.setText(String.format(getString(R.string.danar_model), pump.model, pump.protocol, pump.productCode)); firmwareView.setText(String.format(MainApp.sResources.getString(R.string.danar_model), pump.model, pump.protocol, pump.productCode));
} else { } else {
firmwareView.setText("OLD"); firmwareView.setText("OLD");
} }

View file

@ -258,6 +258,8 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
if (!isInitialized()) if (!isInitialized())
return true; // TODO: not sure what's better. so far TRUE to prevent too many SMS return true; // TODO: not sure what's better. so far TRUE to prevent too many SMS
DanaRKoreanPump pump = getDanaRPump(); DanaRKoreanPump pump = getDanaRPump();
if (pump.pumpProfiles == null)
return true; // TODO: not sure what's better. so far TRUE to prevent too many SMS
int basalValues = pump.basal48Enable ? 48 : 24; int basalValues = pump.basal48Enable ? 48 : 24;
int basalIncrement = pump.basal48Enable ? 30 * 60 : 60 * 60; int basalIncrement = pump.basal48Enable ? 30 * 60 : 60 * 60;
for (int h = 0; h < basalValues; h++) { for (int h = 0; h < basalValues; h++) {
@ -290,17 +292,19 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
@Override @Override
public double getTempBasalAbsoluteRate() { public double getTempBasalAbsoluteRate() {
if (isRealTempBasalInProgress()) { TempBasal tb = getRealTempBasal();
if (getRealTempBasal().isAbsolute) { if (tb != null) {
return getRealTempBasal().absolute; if (tb.isAbsolute) {
return tb.absolute;
} else { } else {
Double baseRate = getBaseBasalRate(); Double baseRate = getBaseBasalRate();
Double tempRate = baseRate * (getRealTempBasal().percent / 100d); Double tempRate = baseRate * (tb.percent / 100d);
return tempRate; return tempRate;
} }
} }
if (isExtendedBoluslInProgress() && useExtendedBoluses) { TempBasal eb = getExtendedBolus();
return getBaseBasalRate() + getExtendedBolus().absolute; if (eb != null && useExtendedBoluses) {
return getBaseBasalRate() + eb.absolute;
} }
return 0; return 0;
} }
@ -707,11 +711,12 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
extended.put("PumpIOB", getDanaRPump().iob); extended.put("PumpIOB", getDanaRPump().iob);
// extended.put("LastBolus", getDanaRPump().lastBolusTime.toLocaleString()); // extended.put("LastBolus", getDanaRPump().lastBolusTime.toLocaleString());
// extended.put("LastBolusAmount", getDanaRPump().lastBolusAmount); // extended.put("LastBolusAmount", getDanaRPump().lastBolusAmount);
if (isTempBasalInProgress()) { TempBasal tb = getTempBasal();
if (tb != null) {
extended.put("TempBasalAbsoluteRate", getTempBasalAbsoluteRate()); extended.put("TempBasalAbsoluteRate", getTempBasalAbsoluteRate());
extended.put("TempBasalStart", getTempBasal().timeStart.toLocaleString()); extended.put("TempBasalStart", tb.timeStart.toLocaleString());
extended.put("TempBasalRemaining", getTempBasal().getPlannedRemainingMinutes()); extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes());
extended.put("IsExtended", getTempBasal().isExtended); extended.put("IsExtended", tb.isExtended);
} }
extended.put("BaseBasalRate", getBaseBasalRate()); extended.put("BaseBasalRate", getBaseBasalRate());
try { try {

View file

@ -56,6 +56,7 @@ import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRConnectionStatu
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRSyncStatus; import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRSyncStatus;
import info.nightscout.androidaps.plugins.DanaRKorean.Services.ExecutionService; import info.nightscout.androidaps.plugins.DanaRKorean.Services.ExecutionService;
import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.SafeParse;
import info.nightscout.utils.ToastUtils; import info.nightscout.utils.ToastUtils;
public class DanaRStatsActivity extends Activity { public class DanaRStatsActivity extends Activity {
@ -366,7 +367,7 @@ public class DanaRStatsActivity extends Activity {
return; return;
} }
else { else {
magicNumber = Double.parseDouble(TBB); magicNumber = SafeParse.stringToDouble(TBB);
} }
magicNumber *=2; magicNumber *=2;

View file

@ -124,7 +124,7 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
@Override @Override
public void run() { public void run() {
if (c.sStatus == c.CONNECTING) { if (c.sStatus == c.CONNECTING) {
statusView.setText(String.format(getString(R.string.danar_history_connectingfor), c.sSecondsElapsed)); statusView.setText(String.format(MainApp.sResources.getString(R.string.danar_history_connectingfor), c.sSecondsElapsed));
} else if (c.sStatus == c.CONNECTED) { } else if (c.sStatus == c.CONNECTED) {
statusView.setText(MainApp.sResources.getString(R.string.connected)); statusView.setText(MainApp.sResources.getString(R.string.connected));
} else { } else {

View file

@ -21,6 +21,7 @@ public class Notification {
public static final int FAILED_UDPATE_PROFILE = 6; public static final int FAILED_UDPATE_PROFILE = 6;
public static final int BASAL_VALUE_BELOW_MINIMUM = 7; public static final int BASAL_VALUE_BELOW_MINIMUM = 7;
public static final int OLD_NSCLIENT = 8; public static final int OLD_NSCLIENT = 8;
public static final int INVALID_PHONE_NUMBER = 9;
public int id; public int id;
public Date date; public Date date;

View file

@ -237,7 +237,7 @@ public class OverviewFragment extends Fragment {
acceptTempButton.setOnClickListener(new View.OnClickListener() { acceptTempButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
MainApp.getConfigBuilder().getActiveLoop().invoke("Accept temp button", false); ConfigBuilderPlugin.getActiveLoop().invoke("Accept temp button", false);
final LoopPlugin.LastRun finalLastRun = LoopPlugin.lastRun; final LoopPlugin.LastRun finalLastRun = LoopPlugin.lastRun;
if (finalLastRun != null && finalLastRun.lastAPSRun != null && finalLastRun.constraintsProcessed.changeRequested) { if (finalLastRun != null && finalLastRun.lastAPSRun != null && finalLastRun.constraintsProcessed.changeRequested) {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
@ -564,7 +564,7 @@ public class OverviewFragment extends Fragment {
showAcceptButton = showAcceptButton && (finalLastRun.lastOpenModeAccept == null || finalLastRun.lastOpenModeAccept.getTime() < finalLastRun.lastAPSRun.getTime()); // never accepted or before last result showAcceptButton = showAcceptButton && (finalLastRun.lastOpenModeAccept == null || finalLastRun.lastOpenModeAccept.getTime() < finalLastRun.lastAPSRun.getTime()); // never accepted or before last result
showAcceptButton = showAcceptButton && finalLastRun.constraintsProcessed.changeRequested; // change is requested showAcceptButton = showAcceptButton && finalLastRun.constraintsProcessed.changeRequested; // change is requested
if (showAcceptButton && pump.isInitialized()) { if (showAcceptButton && pump.isInitialized() && ConfigBuilderPlugin.getActiveLoop() != null) {
acceptTempLayout.setVisibility(View.VISIBLE); acceptTempLayout.setVisibility(View.VISIBLE);
acceptTempButton.setText(getContext().getString(R.string.setbasalquestion) + "\n" + finalLastRun.constraintsProcessed); acceptTempButton.setText(getContext().getString(R.string.setbasalquestion) + "\n" + finalLastRun.constraintsProcessed);
} else { } else {

View file

@ -31,6 +31,8 @@ import info.nightscout.androidaps.plugins.DanaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanPlugin; import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanPlugin;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin; import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.IobTotal;
import info.nightscout.androidaps.plugins.Overview.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventNewSMS; import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventNewSMS;
import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventSmsCommunicatorUpdateGui; import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventSmsCommunicatorUpdateGui;
import info.nightscout.client.data.NSProfile; import info.nightscout.client.data.NSProfile;
@ -446,8 +448,13 @@ public class SmsCommunicatorPlugin implements PluginBase {
SmsManager smsManager = SmsManager.getDefault(); SmsManager smsManager = SmsManager.getDefault();
sms.text = stripAccents(sms.text); sms.text = stripAccents(sms.text);
if (sms.text.length() > 140) sms.text = sms.text.substring(0, 139); if (sms.text.length() > 140) sms.text = sms.text.substring(0, 139);
try {
smsManager.sendTextMessage(sms.phoneNumber, null, sms.text, null, null); smsManager.sendTextMessage(sms.phoneNumber, null, sms.text, null, null);
messages.add(sms); messages.add(sms);
} catch (IllegalArgumentException e) {
Notification notification = new Notification(Notification.INVALID_PHONE_NUMBER, MainApp.sResources.getString(R.string.smscommunicator_invalidphonennumber), Notification.NORMAL);
MainApp.bus().post(new EventNewNotification(notification));
}
} }
private String generatePasscode() { private String generatePasscode() {

View file

@ -113,7 +113,6 @@ public class PersistentNotificationPlugin implements PluginBase{
if(profile != null && lastBG != null) { if(profile != null && lastBG != null) {
line1 = lastBG.valueToUnitsToString(profile.getUnits()); line1 = lastBG.valueToUnitsToString(profile.getUnits());
}
if (glucoseStatus != null) { if (glucoseStatus != null) {
line1 += " Δ" + deltastring(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, profile.getUnits()) line1 += " Δ" + deltastring(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, profile.getUnits())
+ " avgΔ" + deltastring(glucoseStatus.avgdelta, glucoseStatus.avgdelta * Constants.MGDL_TO_MMOLL, profile.getUnits()); + " avgΔ" + deltastring(glucoseStatus.avgdelta, glucoseStatus.avgdelta * Constants.MGDL_TO_MMOLL, profile.getUnits());
@ -122,6 +121,7 @@ public class PersistentNotificationPlugin implements PluginBase{
ctx.getString(R.string.old_data) + ctx.getString(R.string.old_data) +
" "; " ";
} }
}
PumpInterface pump = MainApp.getConfigBuilder(); PumpInterface pump = MainApp.getConfigBuilder();

View file

@ -439,4 +439,6 @@
<string name="profile">Profil</string> <string name="profile">Profil</string>
<string name="short_tabtitles">Krátké názvy modulů</string> <string name="short_tabtitles">Krátké názvy modulů</string>
<string name="virtualpump_firmware_label">Firmware:</string> <string name="virtualpump_firmware_label">Firmware:</string>
<string name="smscommunicator_invalidphonennumber">Špatné telefonní číslo</string>
<string name="tempbasaldeliveryerror">Chyba nastavování dočasného bazálu</string>
</resources> </resources>

View file

@ -475,4 +475,5 @@
<string name="error_only_numeric_digits_range_allowed">Only numeric digits within the range %1$s - %2$s are allowed.</string> <string name="error_only_numeric_digits_range_allowed">Only numeric digits within the range %1$s - %2$s are allowed.</string>
<string name="error_field_must_not_be_empty">The field must not be empty</string> <string name="error_field_must_not_be_empty">The field must not be empty</string>
<string name="error_phone_not_valid">Phone number not valid</string> <string name="error_phone_not_valid">Phone number not valid</string>
<string name="smscommunicator_invalidphonennumber">Invalid SMS phone number</string>
</resources> </resources>