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) {
|
boolean isCommand(String command, String number) {
|
||||||
switch(command.toUpperCase()) {
|
switch (command.toUpperCase()) {
|
||||||
case "BG":
|
case "BG":
|
||||||
case "LOOP":
|
case "LOOP":
|
||||||
case "TREATMENTS":
|
case "TREATMENTS":
|
||||||
|
@ -760,11 +760,18 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
||||||
void sendSMS(Sms sms) {
|
void sendSMS(Sms sms) {
|
||||||
SmsManager smsManager = SmsManager.getDefault();
|
SmsManager smsManager = SmsManager.getDefault();
|
||||||
sms.text = stripAccents(sms.text);
|
sms.text = stripAccents(sms.text);
|
||||||
if (sms.text.length() > 140) sms.text = sms.text.substring(0, 139);
|
|
||||||
try {
|
try {
|
||||||
if (L.isEnabled(L.SMS))
|
if (L.isEnabled(L.SMS))
|
||||||
log.debug("Sending SMS to " + sms.phoneNumber + ": " + sms.text);
|
log.debug("Sending SMS to " + sms.phoneNumber + ": " + sms.text);
|
||||||
|
if (sms.text.getBytes().length <= 140)
|
||||||
smsManager.sendTextMessage(sms.phoneNumber, null, sms.text, null, null);
|
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);
|
messages.add(sms);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
Notification notification = new Notification(Notification.INVALID_PHONE_NUMBER, MainApp.gs(R.string.smscommunicator_invalidphonennumber), Notification.NORMAL);
|
Notification notification = new Notification(Notification.INVALID_PHONE_NUMBER, MainApp.gs(R.string.smscommunicator_invalidphonennumber), Notification.NORMAL);
|
||||||
|
|
Loading…
Reference in a new issue