fixed after review.
This commit is contained in:
parent
4af06620fb
commit
94390ca32f
1 changed files with 19 additions and 27 deletions
|
@ -471,45 +471,37 @@ class SmsCommunicatorPlugin @Inject constructor(
|
||||||
loopPlugin.suspendTo(0L)
|
loopPlugin.suspendTo(0L)
|
||||||
sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.smscommunicator_reconnect)))
|
sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.smscommunicator_reconnect)))
|
||||||
rxBus.send(EventRefreshOverview("SMS_PUMP_START"))
|
rxBus.send(EventRefreshOverview("SMS_PUMP_START"))
|
||||||
sp.putBoolean(R.string.key_objectiveusereconnect, true)
|
|
||||||
loopPlugin.createOfflineEvent(0)
|
loopPlugin.createOfflineEvent(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else if (splitted.size == 3) {
|
} else if ((splitted.size == 3) && (splitted[1].equals("DISCONNECT", ignoreCase = true))) {
|
||||||
if (splitted[1].equals("DISCONNECT", ignoreCase = true)) {
|
var duration = SafeParse.stringToInt(splitted[2])
|
||||||
var duration = SafeParse.stringToInt(splitted[2])
|
duration = Math.max(0, duration)
|
||||||
duration = Math.max(0, duration)
|
duration = Math.min(120, duration)
|
||||||
duration = Math.min(120, duration)
|
if (duration == 0) {
|
||||||
if (duration == 0) {
|
receivedSms.processed = true
|
||||||
receivedSms.processed = true
|
sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.smscommunicator_wrongduration)))
|
||||||
sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.smscommunicator_wrongduration)))
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
val passCode = generatePasscode()
|
|
||||||
val reply = String.format(resourceHelper.gs(R.string.smscommunicator_pumpdisconnectwithcode), duration, passCode)
|
|
||||||
receivedSms.processed = true
|
|
||||||
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() {
|
|
||||||
override fun run() {
|
|
||||||
val profile = profileFunction.getProfile()
|
|
||||||
loopPlugin.disconnectPump(duration, profile)
|
|
||||||
rxBus.send(EventRefreshOverview("SMS_PUMP_DISCONNECT"))
|
|
||||||
sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.smscommunicator_pumpdisconnected)))
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat)))
|
|
||||||
return
|
return
|
||||||
|
} else {
|
||||||
|
val passCode = generatePasscode()
|
||||||
|
val reply = String.format(resourceHelper.gs(R.string.smscommunicator_pumpdisconnectwithcode), duration, passCode)
|
||||||
|
receivedSms.processed = true
|
||||||
|
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() {
|
||||||
|
override fun run() {
|
||||||
|
val profile = profileFunction.getProfile()
|
||||||
|
loopPlugin.disconnectPump(duration, profile)
|
||||||
|
rxBus.send(EventRefreshOverview("SMS_PUMP_DISCONNECT"))
|
||||||
|
sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.smscommunicator_pumpdisconnected)))
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat)))
|
sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat)))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun processPROFILE(splitted: Array<String>, receivedSms: Sms) { // load profiles
|
private fun processPROFILE(splitted: Array<String>, receivedSms: Sms) { // load profiles
|
||||||
|
|
Loading…
Reference in a new issue