Merge pull request #1725 from Lexsus/fix_big_sms_bg
fix error with big sms text in UTF-8
This commit is contained in:
commit
9ca179ec14
1 changed files with 10 additions and 3 deletions
|
@ -118,7 +118,7 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
}
|
||||
|
||||
boolean isCommand(String command, String number) {
|
||||
switch(command.toUpperCase()) {
|
||||
switch (command.toUpperCase()) {
|
||||
case "BG":
|
||||
case "LOOP":
|
||||
case "TREATMENTS":
|
||||
|
@ -760,11 +760,18 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
|||
void sendSMS(Sms sms) {
|
||||
SmsManager smsManager = SmsManager.getDefault();
|
||||
sms.text = stripAccents(sms.text);
|
||||
if (sms.text.length() > 140) sms.text = sms.text.substring(0, 139);
|
||||
|
||||
try {
|
||||
if (L.isEnabled(L.SMS))
|
||||
log.debug("Sending SMS to " + sms.phoneNumber + ": " + sms.text);
|
||||
smsManager.sendTextMessage(sms.phoneNumber, null, sms.text, null, null);
|
||||
if (sms.text.getBytes().length <= 140)
|
||||
smsManager.sendTextMessage(sms.phoneNumber, null, sms.text, null, null);
|
||||
else {
|
||||
ArrayList<String> parts = smsManager.divideMessage(sms.text);
|
||||
smsManager.sendMultipartTextMessage(sms.phoneNumber, null, parts,
|
||||
null, null);
|
||||
}
|
||||
|
||||
messages.add(sms);
|
||||
} catch (IllegalArgumentException e) {
|
||||
Notification notification = new Notification(Notification.INVALID_PHONE_NUMBER, MainApp.gs(R.string.smscommunicator_invalidphonennumber), Notification.NORMAL);
|
||||
|
|
Loading…
Reference in a new issue