From 128547d1a5d7a9736fcc0dbc197b010c9d45fce3 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 27 Jan 2020 23:56:02 +0100 Subject: [PATCH] Fix remote bolus distance --- .../general/smsCommunicator/SmsCommunicatorPlugin.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt index 05a78bfb67..c180dffe83 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt @@ -191,6 +191,12 @@ object SmsCommunicatorPlugin : PluginBase(PluginDescription() log.debug(receivedSms.toString()) val splitted = receivedSms.text.split(Regex("\\s+")).toTypedArray() val remoteCommandsAllowed = SP.getBoolean(R.string.key_smscommunicator_remotecommandsallowed, false) + + val minDistance = + if (areMoreNumbers(SP.getString(R.string.key_smscommunicator_allowednumbers, ""))) + T.mins(SP.getLong(R.string.key_smscommunicator_remotebolusmindistance, T.msecs(Constants.remoteBolusMinDistance).mins())).msecs() + else Constants.remoteBolusMinDistance + if (splitted.isNotEmpty() && isCommand(splitted[0].toUpperCase(Locale.getDefault()), receivedSms.phoneNumber)) { when (splitted[0].toUpperCase(Locale.getDefault())) { "BG" -> @@ -223,7 +229,7 @@ object SmsCommunicatorPlugin : PluginBase(PluginDescription() else sendSMS(Sms(receivedSms.phoneNumber, R.string.wrongformat)) "BOLUS" -> if (!remoteCommandsAllowed) sendSMS(Sms(receivedSms.phoneNumber, R.string.smscommunicator_remotecommandnotallowed)) - else if (splitted.size == 2 && DateUtil.now() - lastRemoteBolusTime < Constants.remoteBolusMinDistance) sendSMS(Sms(receivedSms.phoneNumber, R.string.smscommunicator_remotebolusnotallowed)) + else if (splitted.size == 2 && DateUtil.now() - lastRemoteBolusTime < minDistance) sendSMS(Sms(receivedSms.phoneNumber, R.string.smscommunicator_remotebolusnotallowed)) else if (splitted.size == 2 && pump.isSuspended) sendSMS(Sms(receivedSms.phoneNumber, R.string.pumpsuspended)) else if (splitted.size == 2 || splitted.size == 3) processBOLUS(splitted, receivedSms) else sendSMS(Sms(receivedSms.phoneNumber, R.string.wrongformat))