From 0c97609286ebae225c3b1428a9809e2789854b37 Mon Sep 17 00:00:00 2001 From: moparisthebest Date: Fri, 8 Dec 2017 01:34:09 -0500 Subject: [PATCH] Add support for sending long (multi-part) SMS messages --- .../java/eu/siacs/conversations/services/SMSReceiver.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/eu/siacs/conversations/services/SMSReceiver.java b/src/main/java/eu/siacs/conversations/services/SMSReceiver.java index 81dae436..99f0761e 100644 --- a/src/main/java/eu/siacs/conversations/services/SMSReceiver.java +++ b/src/main/java/eu/siacs/conversations/services/SMSReceiver.java @@ -12,6 +12,8 @@ import eu.siacs.conversations.xml.Element; import eu.siacs.conversations.xmpp.jid.Jid; import eu.siacs.conversations.xmpp.stanzas.MessagePacket; +import java.util.ArrayList; + public class SMSReceiver extends BroadcastReceiver { public static final String ECHO_SERVER = "echo.burtrum.org"; @@ -95,7 +97,11 @@ public class SMSReceiver extends BroadcastReceiver { new Thread(new Runnable() { public void run() { final SmsManager sms = SmsManager.getDefault(); - sms.sendTextMessage(message.getConversation().getJid().getLocalpart(), null, message.getBody(), null, null); + final ArrayList parts = sms.divideMessage(message.getBody()); + if(parts.size() > 1) + sms.sendMultipartTextMessage(message.getConversation().getJid().getLocalpart(), null, parts, null, null); + else + sms.sendTextMessage(message.getConversation().getJid().getLocalpart(), null, message.getBody(), null, null); } }).start(); }