warn on wrong entered sms phone number

This commit is contained in:
Milos Kozak 2017-02-09 16:14:09 +01:00
parent c015862239
commit 7f123e4208
4 changed files with 13 additions and 2 deletions

View file

@ -21,6 +21,7 @@ public class Notification {
public static final int FAILED_UDPATE_PROFILE = 6;
public static final int BASAL_VALUE_BELOW_MINIMUM = 7;
public static final int OLD_NSCLIENT = 8;
public static final int INVALID_PHONE_NUMBER = 9;
public int id;
public Date date;

View file

@ -31,6 +31,8 @@ import info.nightscout.androidaps.plugins.DanaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanPlugin;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.data.IobTotal;
import info.nightscout.androidaps.plugins.Overview.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventNewSMS;
import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventSmsCommunicatorUpdateGui;
import info.nightscout.client.data.NSProfile;
@ -446,8 +448,13 @@ public class SmsCommunicatorPlugin implements PluginBase {
SmsManager smsManager = SmsManager.getDefault();
sms.text = stripAccents(sms.text);
if (sms.text.length() > 140) sms.text = sms.text.substring(0, 139);
smsManager.sendTextMessage(sms.phoneNumber, null, sms.text, null, null);
messages.add(sms);
try {
smsManager.sendTextMessage(sms.phoneNumber, null, sms.text, null, null);
messages.add(sms);
} catch (IllegalArgumentException e) {
Notification notification = new Notification(Notification.INVALID_PHONE_NUMBER, MainApp.sResources.getString(R.string.smscommunicator_invalidphonennumber), Notification.NORMAL);
MainApp.bus().post(new EventNewNotification(notification));
}
}
private String generatePasscode() {

View file

@ -439,4 +439,6 @@
<string name="profile">Profil</string>
<string name="short_tabtitles">Krátké názvy modulů</string>
<string name="virtualpump_firmware_label">Firmware:</string>
<string name="smscommunicator_invalidphonennumber">Špatné telefonní číslo</string>
<string name="tempbasaldeliveryerror">Chyba nastavování dočasného bazálu</string>
</resources>

View file

@ -453,4 +453,5 @@
<string name="virtualpump_firmware_label">Firmware:</string>
<string formatted="false" name="danar_model">Model: %02X Protocol: %02X Code: %02X</string>
<string name="profile">Profile</string>
<string name="smscommunicator_invalidphonennumber">Invalid SMS phone number</string>
</resources>