forked from MilosKozak/AndroidAPS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request MilosKozak#2222 from MilosKozak/2186
New SMS commands
- Loading branch information
Showing
28 changed files
with
1,708 additions
and
1,370 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 0 additions & 59 deletions
59
...src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/AuthRequest.java
This file was deleted.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/AuthRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package info.nightscout.androidaps.plugins.general.smsCommunicator | ||
|
||
import info.nightscout.androidaps.Constants | ||
import info.nightscout.androidaps.R | ||
import info.nightscout.androidaps.logging.L | ||
import info.nightscout.androidaps.utils.DateUtil | ||
import org.slf4j.LoggerFactory | ||
|
||
class AuthRequest internal constructor(val plugin: SmsCommunicatorPlugin, var requester: Sms, requestText: String, var confirmCode: String, val action: SmsAction) { | ||
private val log = LoggerFactory.getLogger(L.SMS) | ||
|
||
private val date = DateUtil.now() | ||
private var processed = false | ||
|
||
init { | ||
plugin.sendSMS(Sms(requester.phoneNumber, requestText)) | ||
} | ||
|
||
fun action(codeReceived: String) { | ||
if (processed) { | ||
if (L.isEnabled(L.SMS)) log.debug("Already processed") | ||
return | ||
} | ||
if (confirmCode != codeReceived) { | ||
processed = true | ||
if (L.isEnabled(L.SMS)) log.debug("Wrong code") | ||
plugin.sendSMS(Sms(requester.phoneNumber, R.string.sms_wrongcode)) | ||
return | ||
} | ||
if (DateUtil.now() - date < Constants.SMS_CONFIRM_TIMEOUT) { | ||
processed = true | ||
if (L.isEnabled(L.SMS)) log.debug("Processing confirmed SMS: " + requester.text) | ||
action.run() | ||
return | ||
} | ||
if (L.isEnabled(L.SMS)) log.debug("Timed out SMS: " + requester.text) | ||
} | ||
} |
42 changes: 0 additions & 42 deletions
42
app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/Sms.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.