]> iEval git - fonbot.git/commitdiff
Handle multi-line SMSes in SmsReceiver
authorMarius Gavrilescu <marius@ieval.ro>
Fri, 22 Mar 2013 11:10:01 +0000 (13:10 +0200)
committerMarius Gavrilescu <marius@ieval.ro>
Fri, 22 Mar 2013 11:10:01 +0000 (13:10 +0200)
src/ro/ieval/fonbot/SmsReceiver.java

index 49d4bea9fad8cedb0501bf3ec883b510a7a037f7..b6fce8e6276cd503e97d27993f921c0ad3b27f85 100644 (file)
@@ -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++) {
This page took 0.023434 seconds and 4 git commands to generate.