merge changes from origin/dev

This commit is contained in:
piotrek 2022-12-04 22:18:48 +01:00
parent db6409bb69
commit 1c8354a949
2 changed files with 19 additions and 19 deletions

View file

@ -510,8 +510,8 @@ class SmsCommunicatorPlugin @Inject constructor(
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(pumpCommand = false) { messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(pumpCommand = false) {
override fun run() { override fun run() {
uel.log(Action.LGS_LOOP_MODE, Sources.SMS) uel.log(Action.LGS_LOOP_MODE, Sources.SMS)
sp.putString(R.string.key_aps_mode, ApsMode.LGS.lowercase) sp.putString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.LGS.lowercase)
rxBus.send(EventPreferenceChange(rh.gs(R.string.lowglucosesuspend))) rxBus.send(EventPreferenceChange(rh.gs(info.nightscout.core.ui.R.string.lowglucosesuspend)))
val replyText = rh.gs(R.string.smscommunicator_current_loop_mode, getApsModeText()) val replyText = rh.gs(R.string.smscommunicator_current_loop_mode, getApsModeText())
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
} }
@ -525,8 +525,8 @@ class SmsCommunicatorPlugin @Inject constructor(
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(pumpCommand = false) { messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(pumpCommand = false) {
override fun run() { override fun run() {
uel.log(Action.CLOSED_LOOP_MODE, Sources.SMS) uel.log(Action.CLOSED_LOOP_MODE, Sources.SMS)
sp.putString(R.string.key_aps_mode, ApsMode.CLOSED.lowercase) sp.putString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.CLOSED.lowercase)
rxBus.send(EventPreferenceChange(rh.gs(R.string.closedloop))) rxBus.send(EventPreferenceChange(rh.gs(info.nightscout.core.ui.R.string.closedloop)))
val replyText = rh.gs(R.string.smscommunicator_current_loop_mode, getApsModeText()) val replyText = rh.gs(R.string.smscommunicator_current_loop_mode, getApsModeText())
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
} }
@ -1284,10 +1284,10 @@ class SmsCommunicatorPlugin @Inject constructor(
} }
private fun getApsModeText(): String = private fun getApsModeText(): String =
when (ApsMode.secureValueOf(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.lowercase))) { when (ApsMode.secureValueOf(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.lowercase))) {
ApsMode.OPEN -> rh.gs(R.string.openloop) ApsMode.OPEN -> rh.gs(info.nightscout.core.ui.R.string.openloop)
ApsMode.CLOSED -> rh.gs(R.string.closedloop) ApsMode.CLOSED -> rh.gs(info.nightscout.core.ui.R.string.closedloop)
ApsMode.LGS -> rh.gs(R.string.lowglucosesuspend) ApsMode.LGS -> rh.gs(info.nightscout.core.ui.R.string.lowglucosesuspend)
else -> rh.gs(R.string.unknown) else -> rh.gs(info.nightscout.core.ui.R.string.unknown)
} }
} }

View file

@ -254,10 +254,10 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
`when`(rh.gsNotLocalised(R.string.smscommunicator_tempbasal_canceled)).thenReturn("Temp basal canceled") `when`(rh.gsNotLocalised(R.string.smscommunicator_tempbasal_canceled)).thenReturn("Temp basal canceled")
`when`(rh.gsNotLocalised(R.string.smscommunicator_calibration_sent)).thenReturn("Calibration sent. Receiving must be enabled in xDrip+.") `when`(rh.gsNotLocalised(R.string.smscommunicator_calibration_sent)).thenReturn("Calibration sent. Receiving must be enabled in xDrip+.")
`when`(rh.gsNotLocalised(R.string.smscommunicator_tt_canceled)).thenReturn("Temp Target canceled successfully") `when`(rh.gsNotLocalised(R.string.smscommunicator_tt_canceled)).thenReturn("Temp Target canceled successfully")
`when`(rh.gs(R.string.closedloop)).thenReturn(modeClosed) `when`(rh.gs(info.nightscout.core.ui.R.string.closedloop)).thenReturn(modeClosed)
`when`(rh.gs(R.string.openloop)).thenReturn(modeOpen) `when`(rh.gs(info.nightscout.core.ui.R.string.openloop)).thenReturn(modeOpen)
`when`(rh.gs(R.string.lowglucosesuspend)).thenReturn(modeLgs) `when`(rh.gs(info.nightscout.core.ui.R.string.lowglucosesuspend)).thenReturn(modeLgs)
`when`(rh.gs(R.string.unknown)).thenReturn(modeUnknown) `when`(rh.gs(info.nightscout.core.ui.R.string.unknown)).thenReturn(modeUnknown)
`when`(rh.gs(R.string.smscommunicator_set_closed_loop_reply_with_code)).thenReturn("In order to switch Loop mode to Closed loop reply with code %1\$s") `when`(rh.gs(R.string.smscommunicator_set_closed_loop_reply_with_code)).thenReturn("In order to switch Loop mode to Closed loop reply with code %1\$s")
`when`(rh.gs(R.string.smscommunicator_current_loop_mode)).thenReturn("Current loop mode: %1\$s") `when`(rh.gs(R.string.smscommunicator_current_loop_mode)).thenReturn("Current loop mode: %1\$s")
`when`(rh.gs(R.string.smscommunicator_set_lgs_reply_with_code)).thenReturn("In order to switch Loop mode to LGS (Low Glucose Suspend) reply with code %1\$s") `when`(rh.gs(R.string.smscommunicator_set_lgs_reply_with_code)).thenReturn("In order to switch Loop mode to LGS (Low Glucose Suspend) reply with code %1\$s")
@ -344,7 +344,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
//LOOP STATUS : enabled - APS mode - Closed //LOOP STATUS : enabled - APS mode - Closed
`when`(loop.enabled).thenReturn(true) `when`(loop.enabled).thenReturn(true)
`when`(loop.isSuspended).thenReturn(false) `when`(loop.isSuspended).thenReturn(false)
`when`(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.lowercase)).thenReturn(ApsMode.CLOSED.lowercase) `when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.lowercase)).thenReturn(ApsMode.CLOSED.lowercase)
smsCommunicatorPlugin.messages = ArrayList() smsCommunicatorPlugin.messages = ArrayList()
sms = Sms("1234", "LOOP STATUS") sms = Sms("1234", "LOOP STATUS")
smsCommunicatorPlugin.processSms(sms) smsCommunicatorPlugin.processSms(sms)
@ -353,7 +353,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
Assert.assertEquals("Loop is enabled - $modeClosed", smsCommunicatorPlugin.messages[1].text) Assert.assertEquals("Loop is enabled - $modeClosed", smsCommunicatorPlugin.messages[1].text)
//LOOP STATUS : enabled - APS mode - Open //LOOP STATUS : enabled - APS mode - Open
`when`(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.lowercase)).thenReturn(ApsMode.OPEN.lowercase) `when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.lowercase)).thenReturn(ApsMode.OPEN.lowercase)
smsCommunicatorPlugin.messages = ArrayList() smsCommunicatorPlugin.messages = ArrayList()
smsCommunicatorPlugin.processSms(sms) smsCommunicatorPlugin.processSms(sms)
Assert.assertFalse(sms.ignored) Assert.assertFalse(sms.ignored)
@ -361,7 +361,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
Assert.assertEquals("Loop is enabled - $modeOpen", smsCommunicatorPlugin.messages[1].text) Assert.assertEquals("Loop is enabled - $modeOpen", smsCommunicatorPlugin.messages[1].text)
//LOOP STATUS : enabled - APS mode - LGS //LOOP STATUS : enabled - APS mode - LGS
`when`(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.lowercase)).thenReturn(ApsMode.LGS.lowercase) `when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.lowercase)).thenReturn(ApsMode.LGS.lowercase)
smsCommunicatorPlugin.messages = ArrayList() smsCommunicatorPlugin.messages = ArrayList()
smsCommunicatorPlugin.processSms(sms) smsCommunicatorPlugin.processSms(sms)
Assert.assertFalse(sms.ignored) Assert.assertFalse(sms.ignored)
@ -369,7 +369,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
Assert.assertEquals("Loop is enabled - $modeLgs", smsCommunicatorPlugin.messages[1].text) Assert.assertEquals("Loop is enabled - $modeLgs", smsCommunicatorPlugin.messages[1].text)
//LOOP STATUS : enabled - APS mode - unknown //LOOP STATUS : enabled - APS mode - unknown
`when`(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.lowercase)).thenReturn("some wrong value") `when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.lowercase)).thenReturn("some wrong value")
smsCommunicatorPlugin.messages = ArrayList() smsCommunicatorPlugin.messages = ArrayList()
smsCommunicatorPlugin.processSms(sms) smsCommunicatorPlugin.processSms(sms)
Assert.assertFalse(sms.ignored) Assert.assertFalse(sms.ignored)
@ -521,7 +521,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
var smsCommand = "LOOP CLOSED" var smsCommand = "LOOP CLOSED"
val replyClosed = "In order to switch Loop mode to Closed loop reply with code " val replyClosed = "In order to switch Loop mode to Closed loop reply with code "
`when`(loop.enabled).thenReturn(true) `when`(loop.enabled).thenReturn(true)
`when`(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.lowercase)).thenReturn(ApsMode.CLOSED.lowercase) `when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.lowercase)).thenReturn(ApsMode.CLOSED.lowercase)
smsCommunicatorPlugin.messages = ArrayList() smsCommunicatorPlugin.messages = ArrayList()
sms = Sms("1234", smsCommand) sms = Sms("1234", smsCommand)
smsCommunicatorPlugin.processSms(sms) smsCommunicatorPlugin.processSms(sms)
@ -536,7 +536,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
//LOOP LGS //LOOP LGS
smsCommand = "LOOP LGS" smsCommand = "LOOP LGS"
val replyLgs = "In order to switch Loop mode to LGS (Low Glucose Suspend) reply with code " val replyLgs = "In order to switch Loop mode to LGS (Low Glucose Suspend) reply with code "
`when`(sp.getString(R.string.key_aps_mode, ApsMode.OPEN.lowercase)).thenReturn(ApsMode.LGS.lowercase) `when`(sp.getString(info.nightscout.core.utils.R.string.key_aps_mode, ApsMode.OPEN.lowercase)).thenReturn(ApsMode.LGS.lowercase)
smsCommunicatorPlugin.messages = ArrayList() smsCommunicatorPlugin.messages = ArrayList()
sms = Sms("1234", smsCommand) sms = Sms("1234", smsCommand)
smsCommunicatorPlugin.processSms(sms) smsCommunicatorPlugin.processSms(sms)