Some test code

This commit is contained in:
Mathieu Maret 2010-01-26 18:28:38 +01:00
parent 6c373b51e5
commit 2223c40c93

View File

@ -96,7 +96,7 @@ public class MultiSmsSender extends Activity {
long deliveryId = -1; long deliveryId = -1;
ArrayList<String> messages = manager.divideMessage(message); ArrayList<String> messages = manager.divideMessage(message);
int messageCount = messages.size(); int messageCount = messages.size();
//showDialog(SENDING_DIALOG_KEY); //showDialog(SENDING_DIALOG_KEY);
mSendingDialog = new ProgressDialog(this); mSendingDialog = new ProgressDialog(this);
mSendingDialog.setTitle(R.string.sending); mSendingDialog.setTitle(R.string.sending);
@ -106,7 +106,7 @@ public class MultiSmsSender extends Activity {
mSendingDialog.setCancelable(false); mSendingDialog.setCancelable(false);
mSendingDialog.setMax(size); mSendingDialog.setMax(size);
mSendingDialog.show(); mSendingDialog.show();
if (haveDeliveryReports) { if (haveDeliveryReports) {
deliveryId = mDbHelper.createDelivery(message.substring(0, Math.min(30, message deliveryId = mDbHelper.createDelivery(message.substring(0, Math.min(30, message
.length())).replace('\n', ' '), DateFormat.getDateInstance() .length())).replace('\n', ' '), DateFormat.getDateInstance()
@ -116,28 +116,32 @@ public class MultiSmsSender extends Activity {
if (numbers.length != 0) { if (numbers.length != 0) {
for (int i = 0; i < numbers.length; i++) { for (int i = 0; i < numbers.length; i++) {
String newN = numbers[i].trim(); String newN = numbers[i].trim();
if (!newN.equals("") if (!newN.equals("")
&& PhoneNumberUtils.isWellFormedSmsAddress(newN)) { && PhoneNumberUtils.isWellFormedSmsAddress(newN)) {
mSendingDialog.setProgress(i / size); mSendingDialog.setProgress(i / size);
if (!allreadySend.contains(newN)) { if (!allreadySend.contains(newN)) {
allreadySend.add(newN); allreadySend.add(newN);
ArrayList<PendingIntent> sentIntents = null;
if (haveDeliveryReports) {
sentIntents = new ArrayList<PendingIntent>(messageCount);
long entryId = mDbHelper.createEntry(mDbHelper.nameFromNumber(newN), newN, deliveryId);
ArrayList<PendingIntent> deliveryIntents = new ArrayList<PendingIntent>(messageCount);
ArrayList<PendingIntent> sentIntents = null;
if (haveDeliveryReports) {
long entryId = mDbHelper.createEntry(mDbHelper.nameFromNumber(newN), newN, deliveryId);
for (int j = 0; j < messageCount; j++) { for (int j = 0; j < messageCount; j++) {
Intent intent = new Intent(MessageReceiver.MESSAGE_RECEIVED, null, this, MessageReceiver.class); Intent intent = new Intent(MessageReceiver.MESSAGE_RECEIVED, null, this, MessageReceiver.class);
intent.putExtra(PARAM_ENTRY_ID, entryId); intent.putExtra(PARAM_ENTRY_ID, entryId);
sentIntents.add(PendingIntent.getBroadcast( deliveryIntents.add(PendingIntent.getBroadcast(
this, 0, intent , PendingIntent.FLAG_CANCEL_CURRENT)); this, 0, intent , PendingIntent.FLAG_UPDATE_CURRENT));
} }
} }
manager.sendMultipartTextMessage(newN, null, messages, null, sentIntents); manager.sendMultipartTextMessage(newN, null, messages, deliveryIntents, sentIntents);
} }
} }