From: Marius Gavrilescu Date: Fri, 22 Mar 2013 11:10:01 +0000 (+0200) Subject: Handle multi-line SMSes in SmsReceiver X-Git-Tag: 0.000_001~51 X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=de69decc2c27b489dbe3fa7a674d235b7e97494d;p=fonbot.git Handle multi-line SMSes in SmsReceiver --- diff --git a/src/ro/ieval/fonbot/SmsReceiver.java b/src/ro/ieval/fonbot/SmsReceiver.java index 49d4bea..b6fce8e 100644 --- a/src/ro/ieval/fonbot/SmsReceiver.java +++ b/src/ro/ieval/fonbot/SmsReceiver.java @@ -50,25 +50,24 @@ public final class SmsReceiver extends BroadcastReceiver { final SmsMessage sms=SmsMessage.createFromPdu((byte[]) pdu); final String originAddress=sms.getOriginatingAddress(); if(sms.getMessageBody() == null || originAddress == null) - return; + continue; final String name=Utils.callerId(context, originAddress); + final String body=sms.getMessageBody(); if(name==null) - Utils.sendMessage(context, toNonNull(MessageType.SMS), - toNonNull(context.getString(sms_received_fmt, - originAddress, sms.getMessageBody()))); + Utils.sendMessage(context, toNonNull(MessageType.SMS), sms_received_fmt, + originAddress, body.replace("\n", "\n ")); else - Utils.sendMessage(context, toNonNull(MessageType.SMS), - toNonNull(context.getString(sms_received_fmt, - originAddress+" ("+name+")",sms.getMessageBody()))); + Utils.sendMessage(context, toNonNull(MessageType.SMS), sms_received_fmt, + originAddress+" ("+name+")", body.replace("\n", "\n ")); - final String[] lines=sms.getMessageBody().split("\n"); + final String[] lines=body.split("\n"); final String password = PreferenceManager.getDefaultSharedPreferences(context).getString("smspassword",""); if(password==null||password.length()==0) - return; + continue; if(lines.length==0 || !lines[0].equals(password)) - return; + continue; final Address address=new Address(toNonNull(Protocol.SMS), originAddress);//NOPMD variable depends on originAddress for (int i = 1; i < lines.length; i++) {