4
0
mirror of https://github.com/cwinfo/envayasms.git synced 2025-07-04 05:57:44 +00:00

don't request delivery reports but leave option open in future; fix bug with encoding of apostrophe by php library

This commit is contained in:
Jesse Young
2011-09-27 20:23:36 -07:00
parent 03d5f556d7
commit faffc6c568
5 changed files with 28 additions and 16 deletions

View File

@ -68,12 +68,13 @@ public final class App extends Application {
public static final String OUTGOING_SMS_INTENT_SUFFIX = ".OUTGOING_SMS";
public static final String OUTGOING_SMS_EXTRA_TO = "to";
public static final String OUTGOING_SMS_EXTRA_BODY = "body";
public static final String OUTGOING_SMS_EXTRA_DELIVERY_REPORT = "delivery";
public static final int OUTGOING_SMS_UNHANDLED = Activity.RESULT_FIRST_USER;
// intent for MessageStatusNotifier to receive status updates for outgoing SMS
// (even if sent by an expansion pack)
public static final String MESSAGE_STATUS_INTENT = "org.envaya.sms.MESSAGE_STATUS";
public static final String MESSAGE_DELIVERY_INTENT = "org.envaya.sms.MESSAGE_DELIVERY";
public static final String MESSAGE_DELIVERY_INTENT = "org.envaya.sms.MESSAGE_DELIVERY";
public static final String STATUS_EXTRA_INDEX = "status";
public static final String STATUS_EXTRA_NUM_PARTS = "num_parts";

View File

@ -4,6 +4,7 @@ package org.envaya.sms;
import org.envaya.sms.receiver.OutgoingMessageRetry;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.telephony.SmsManager;
import java.util.ArrayList;
@ -105,6 +106,7 @@ public class OutgoingMessage extends QueuedMessage {
}
Intent intent = new Intent(packageName + App.OUTGOING_SMS_INTENT_SUFFIX, this.getUri());
intent.putExtra(App.OUTGOING_SMS_EXTRA_DELIVERY_REPORT, false);
intent.putExtra(App.OUTGOING_SMS_EXTRA_TO, getTo());
intent.putExtra(App.OUTGOING_SMS_EXTRA_BODY, bodyParts);

View File

@ -16,11 +16,17 @@ public class OutgoingSmsReceiver extends BroadcastReceiver {
Bundle extras = intent.getExtras();
String to = extras.getString(App.OUTGOING_SMS_EXTRA_TO);
ArrayList<String> bodyParts = extras.getStringArrayList(App.OUTGOING_SMS_EXTRA_BODY);
boolean deliveryReport = extras.getBoolean(App.OUTGOING_SMS_EXTRA_DELIVERY_REPORT, false);
SmsManager smgr = SmsManager.getDefault();
ArrayList<PendingIntent> sentIntents = new ArrayList<PendingIntent>();
ArrayList<PendingIntent> deliveryIntents = new ArrayList<PendingIntent>();
ArrayList<PendingIntent> deliveryIntents = null;
if (deliveryReport)
{
deliveryIntents = new ArrayList<PendingIntent>();
}
int numParts = bodyParts.size();
@ -36,15 +42,18 @@ public class OutgoingSmsReceiver extends BroadcastReceiver {
statusIntent,
PendingIntent.FLAG_ONE_SHOT));
Intent deliveryIntent = new Intent(App.MESSAGE_DELIVERY_INTENT, intent.getData());
deliveryIntent.putExtra(App.STATUS_EXTRA_INDEX, i);
deliveryIntent.putExtra(App.STATUS_EXTRA_NUM_PARTS, numParts);
deliveryIntents.add(PendingIntent.getBroadcast(
context,
0,
deliveryIntent,
PendingIntent.FLAG_ONE_SHOT));
if (deliveryReport)
{
Intent deliveryIntent = new Intent(App.MESSAGE_DELIVERY_INTENT, intent.getData());
deliveryIntent.putExtra(App.STATUS_EXTRA_INDEX, i);
deliveryIntent.putExtra(App.STATUS_EXTRA_NUM_PARTS, numParts);
deliveryIntents.add(PendingIntent.getBroadcast(
context,
0,
deliveryIntent,
PendingIntent.FLAG_ONE_SHOT));
}
}
smgr.sendMultipartTextMessage(to, null, bodyParts, sentIntents, deliveryIntents);