From 480542a143d2beeecaaceaa198e8450243a127f1 Mon Sep 17 00:00:00 2001 From: Philoul Date: Sun, 17 May 2020 01:58:07 +0200 Subject: [PATCH 1/2] Fix Wear Control Kotlin doesn't like regex... (AAPS crashed on these lines with ""\\s+", replaced by a space) --- .../androidaps/plugins/general/wear/ActionStringHandler.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.kt index 29ed323ee1..a7f5ee98da 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.kt @@ -86,7 +86,7 @@ class ActionStringHandler @Inject constructor( var rMessage = "" var rAction = "" // do the parsing and check constraints - val act = actionString.split("\\s+").toTypedArray() + val act = actionString.split(" ").toTypedArray() if ("fillpreset" == act[0]) { ///////////////////////////////////// PRIME/FILL val amount: Double = if ("1" == act[1]) { sp.getDouble("fill_button1", 0.3) @@ -470,7 +470,7 @@ class ActionStringHandler @Inject constructor( if (System.currentTimeMillis() - lastSentTimestamp > TIMEOUT) return lastConfirmActionString = null // do the parsing, check constraints and enact! - val act = actionString.split("\\s+").toTypedArray() + val act = actionString.split(" ").toTypedArray() if ("fill" == act[0]) { val amount = SafeParse.stringToDouble(act[1]) val insulinAfterConstraints = constraintChecker.applyBolusConstraints(Constraint(amount)).value() From 72e541908cbc0bb94df16e5027eec62781922fce Mon Sep 17 00:00:00 2001 From: Philoul Date: Sun, 17 May 2020 08:09:58 +0200 Subject: [PATCH 2/2] Revert "Fix Wear Control Kotlin doesn't like regex... (AAPS crashed on these lines with ""\\s+", replaced by a space)" => Second proposal better than my first one, split works with regex if it is of type Regex (it doesn't recognize first \ as a regex string but as an escape character...) This reverts commit 480542a1 --- .../androidaps/plugins/general/wear/ActionStringHandler.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.kt index a7f5ee98da..3aa96ae31d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.kt @@ -86,7 +86,7 @@ class ActionStringHandler @Inject constructor( var rMessage = "" var rAction = "" // do the parsing and check constraints - val act = actionString.split(" ").toTypedArray() + val act = actionString.split("\\s+".toRegex()).toTypedArray() if ("fillpreset" == act[0]) { ///////////////////////////////////// PRIME/FILL val amount: Double = if ("1" == act[1]) { sp.getDouble("fill_button1", 0.3) @@ -470,7 +470,7 @@ class ActionStringHandler @Inject constructor( if (System.currentTimeMillis() - lastSentTimestamp > TIMEOUT) return lastConfirmActionString = null // do the parsing, check constraints and enact! - val act = actionString.split(" ").toTypedArray() + val act = actionString.split("\\s+".toRegex()).toTypedArray() if ("fill" == act[0]) { val amount = SafeParse.stringToDouble(act[1]) val insulinAfterConstraints = constraintChecker.applyBolusConstraints(Constraint(amount)).value()