SMS Plugin allow duration in basal command

This commit is contained in:
Milos Kozak 2019-03-08 23:56:35 +01:00
parent 56f977df3c
commit 79b6bc6c43
2 changed files with 21 additions and 4 deletions

View file

@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.general.smsCommunicator;
abstract class SmsAction implements Runnable { abstract class SmsAction implements Runnable {
Double aDouble; Double aDouble;
Integer anInteger; Integer anInteger;
Integer secondInteger;
SmsAction() {} SmsAction() {}
@ -10,7 +11,17 @@ abstract class SmsAction implements Runnable {
this.aDouble = aDouble; this.aDouble = aDouble;
} }
SmsAction(Double aDouble, Integer secondInteger) {
this.aDouble = aDouble;
this.secondInteger = secondInteger;
}
SmsAction(Integer anInteger) { SmsAction(Integer anInteger) {
this.anInteger = anInteger; this.anInteger = anInteger;
} }
SmsAction(Integer anInteger, Integer secondInteger) {
this.anInteger = anInteger;
this.secondInteger = secondInteger;
}
} }

View file

@ -363,6 +363,9 @@ public class SmsCommunicatorPlugin extends PluginBase {
} }
} else if (splited[1].endsWith("%")) { } else if (splited[1].endsWith("%")) {
int tempBasalPct = SafeParse.stringToInt(StringUtils.removeEnd(splited[1],"%")); int tempBasalPct = SafeParse.stringToInt(StringUtils.removeEnd(splited[1],"%"));
int duration = 30;
if (splited.length > 2)
duration = SafeParse.stringToInt(splited[2]);
Profile profile = ProfileFunctions.getInstance().getProfile(); Profile profile = ProfileFunctions.getInstance().getProfile();
if (profile == null) { if (profile == null) {
reply = MainApp.gs(R.string.noprofile); reply = MainApp.gs(R.string.noprofile);
@ -376,12 +379,12 @@ public class SmsCommunicatorPlugin extends PluginBase {
passCode = generatePasscode(); passCode = generatePasscode();
reply = String.format(MainApp.gs(R.string.smscommunicator_basalpctreplywithcode), tempBasalPct, passCode); reply = String.format(MainApp.gs(R.string.smscommunicator_basalpctreplywithcode), tempBasalPct, passCode);
receivedSms.processed = true; receivedSms.processed = true;
messageToConfirm = new AuthRequest(this, receivedSms, reply, passCode, new SmsAction(tempBasalPct) { messageToConfirm = new AuthRequest(this, receivedSms, reply, passCode, new SmsAction(tempBasalPct, duration) {
@Override @Override
public void run() { public void run() {
Profile profile = ProfileFunctions.getInstance().getProfile(); Profile profile = ProfileFunctions.getInstance().getProfile();
if (profile != null) if (profile != null)
ConfigBuilderPlugin.getPlugin().getCommandQueue().tempBasalPercent(anInteger, 30, true, profile, new Callback() { ConfigBuilderPlugin.getPlugin().getCommandQueue().tempBasalPercent(anInteger, secondInteger, true, profile, new Callback() {
@Override @Override
public void run() { public void run() {
if (result.success) { if (result.success) {
@ -408,6 +411,9 @@ public class SmsCommunicatorPlugin extends PluginBase {
} }
} else { } else {
Double tempBasal = SafeParse.stringToDouble(splited[1]); Double tempBasal = SafeParse.stringToDouble(splited[1]);
int duration = 30;
if (splited.length > 2)
duration = SafeParse.stringToInt(splited[2]);
Profile profile = ProfileFunctions.getInstance().getProfile(); Profile profile = ProfileFunctions.getInstance().getProfile();
if (profile == null) { if (profile == null) {
reply = MainApp.gs(R.string.noprofile); reply = MainApp.gs(R.string.noprofile);
@ -418,12 +424,12 @@ public class SmsCommunicatorPlugin extends PluginBase {
passCode = generatePasscode(); passCode = generatePasscode();
reply = String.format(MainApp.gs(R.string.smscommunicator_basalreplywithcode), tempBasal, passCode); reply = String.format(MainApp.gs(R.string.smscommunicator_basalreplywithcode), tempBasal, passCode);
receivedSms.processed = true; receivedSms.processed = true;
messageToConfirm = new AuthRequest(this, receivedSms, reply, passCode, new SmsAction(tempBasal) { messageToConfirm = new AuthRequest(this, receivedSms, reply, passCode, new SmsAction(tempBasal, duration) {
@Override @Override
public void run() { public void run() {
Profile profile = ProfileFunctions.getInstance().getProfile(); Profile profile = ProfileFunctions.getInstance().getProfile();
if (profile != null) if (profile != null)
ConfigBuilderPlugin.getPlugin().getCommandQueue().tempBasalAbsolute(aDouble, 30, true, profile, new Callback() { ConfigBuilderPlugin.getPlugin().getCommandQueue().tempBasalAbsolute(aDouble, secondInteger, true, profile, new Callback() {
@Override @Override
public void run() { public void run() {
if (result.success) { if (result.success) {