Delivery Report working correctly :)
This commit is contained in:
parent
e72d637222
commit
90a6a1a886
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.openwide.android" android:versionCode="4"
|
||||
android:versionName="1.0.2">
|
||||
package="com.openwide.android" android:versionCode="5"
|
||||
android:versionName="1.1.0">
|
||||
<application android:label="@string/app_name" android:icon="@drawable/multisms">
|
||||
<activity android:name=".MultiSmsSender" android:label="@string/app_name">
|
||||
<intent-filter>
|
||||
@ -16,10 +16,12 @@
|
||||
<activity android:name="ListEntryActivity"></activity>
|
||||
<receiver android:name=".MessageReceiver" android:enabled="true" >
|
||||
<intent-filter>
|
||||
<action android:name="android.provider.Telephony.SMS_RECEIVED"/>
|
||||
<action android:name="com.openwide.android.SMS_RECEIVED"/>
|
||||
<data android:mimeType="com.openwide.android.item/entry"/>
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
</application>
|
||||
<provider android:authorities="com.openwide.android" android:name="EntryContentProvider"></provider>
|
||||
</application>
|
||||
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="4" />
|
||||
<supports-screens android:smallScreens="true"
|
||||
android:anyDensity="true" />
|
||||
|
@ -32,10 +32,10 @@ public class DeliveryDbAdapter {
|
||||
* Database creation sql statement
|
||||
*/
|
||||
|
||||
private static final String DATABASE_NAME = "data";
|
||||
private static final String DATABASE_DELIVERY_ENTRY_TABLE = "delivery_entry";
|
||||
private static final String DATABASE_DELIVERY_TABLE = "delivery";
|
||||
private static final String DATABASE_DELIVERY_ENTRY_CREATE = "create table "
|
||||
public static final String DATABASE_NAME = "data";
|
||||
public static final String DATABASE_DELIVERY_ENTRY_TABLE = "delivery_entry";
|
||||
public static final String DATABASE_DELIVERY_TABLE = "delivery";
|
||||
public static final String DATABASE_DELIVERY_ENTRY_CREATE = "create table "
|
||||
+ DATABASE_DELIVERY_ENTRY_TABLE
|
||||
+ " ("+KEY_DELIVERY_ENTRY_ROWID+" integer primary key autoincrement, "
|
||||
+ KEY_DELIVERY_ENTRY_NAME + " text not null,"
|
||||
@ -43,13 +43,13 @@ public class DeliveryDbAdapter {
|
||||
+ KEY_DELIVERY_ENTRY_DELIVERED + " integer,"
|
||||
+ KEY_DELIVERY_ENTRY_DELIVERY_ID + " integer);";
|
||||
|
||||
private static final String DATABASE_DELIVERY_CREATE = "create table "
|
||||
public static final String DATABASE_DELIVERY_CREATE = "create table "
|
||||
+ DATABASE_DELIVERY_TABLE
|
||||
+ " (" + KEY_DELIVERY_ROWID + " integer primary key autoincrement, "
|
||||
+ KEY_DELIVERY_NAME + " text not null,"
|
||||
+ KEY_DELIVERY_DATE + " text not null);";
|
||||
|
||||
private static final int DATABASE_VERSION = 2;
|
||||
public static final int DATABASE_VERSION = 3;
|
||||
|
||||
private final Context mCtx;
|
||||
|
||||
|
78
src/com/openwide/android/EntryContentProvider.java
Normal file
78
src/com/openwide/android/EntryContentProvider.java
Normal file
@ -0,0 +1,78 @@
|
||||
package com.openwide.android;
|
||||
|
||||
import android.content.ContentProvider;
|
||||
import android.content.ContentValues;
|
||||
import android.content.UriMatcher;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
|
||||
/**
|
||||
*
|
||||
* This class is not very usefull... It have been created so we can set Uri for deliveryEntry in the database.
|
||||
* Thanks to this, sending a SMS (function sendMultipartTextMessage in MultiSmsSender) with a PendingIntent for delivery reports will use different Intent (Intent i = new Intent(message, uri))
|
||||
* so PendingIntent.getBroadcast() will return different PendingIntent
|
||||
*
|
||||
* @author mathieu
|
||||
*
|
||||
*/
|
||||
public class EntryContentProvider extends ContentProvider{
|
||||
public static final String PROVIDER_NAME="com.openwide.android";
|
||||
public static final Uri CONTENT_URI =
|
||||
Uri.parse("content://"+PROVIDER_NAME+ "/entries");
|
||||
|
||||
|
||||
|
||||
private static final int ENTRIES = 1;
|
||||
private static final int ENTRY_ID = 2;
|
||||
|
||||
private static final UriMatcher uriMatcher;
|
||||
static{
|
||||
uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "entries", ENTRIES);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "entries/#", ENTRY_ID);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int delete(Uri uri, String selection, String[] selectionArgs) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType(Uri uri) {
|
||||
switch (uriMatcher.match(uri)){
|
||||
case ENTRIES:
|
||||
return "com.openwide.android.dir/entry ";
|
||||
case ENTRY_ID:
|
||||
return "com.openwide.android.item/entry ";
|
||||
default:
|
||||
throw new IllegalArgumentException("Unsupported URI: " + uri);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uri insert(Uri uri, ContentValues values) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreate() {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cursor query(Uri uri, String[] projection, String selection,
|
||||
String[] selectionArgs, String sortOrder) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(Uri uri, ContentValues values, String selection,
|
||||
String[] selectionArgs) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -46,6 +46,7 @@ public class GroupEditActivity extends ListActivity {
|
||||
String groupName = groupNameCursor.getString(groupNameCursor.getColumnIndex(GroupsDbAdapter.KEY_GROUP_NAME));
|
||||
mGroupNameText.setText(groupName);
|
||||
Cursor numbers = mDb.fetchPhonesFromGroup(groupId);
|
||||
startManagingCursor(numbers);
|
||||
numbers.moveToFirst();
|
||||
int phoneNumIdx = numbers.getColumnIndex(Phones.NUMBER);
|
||||
mSelected = new String[numbers.getCount()];
|
||||
|
@ -3,22 +3,28 @@ package com.openwide.android;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.net.Uri;
|
||||
import android.util.Log;
|
||||
|
||||
public class MessageReceiver extends BroadcastReceiver{
|
||||
public static final String MESSAGE_RECEIVED = "com.openwide.android.SMS_RECEIVED";
|
||||
public static final String ANDROID_MESSAGE_RECEIVED = "android.provider.Telephony.SMS_RECEIVED";
|
||||
public static final String DEBUG_TAG="-------MessageReceiver--------";
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
|
||||
|
||||
Log.d("------------------", "WORKING :)!!!!");
|
||||
if (ANDROID_MESSAGE_RECEIVED.equals(intent.getAction())) {
|
||||
if (MESSAGE_RECEIVED.equals(intent.getAction())) {
|
||||
Log.d(DEBUG_TAG, "SMS_RECEIVED");
|
||||
Long entryId;
|
||||
Bundle extras = intent.getExtras();
|
||||
entryId = extras != null ? extras.getLong(MultiSmsSender.PARAM_ENTRY_ID): null;
|
||||
//Bundle extras = intent.getExtras();
|
||||
//entryId = extras != null ? extras.getLong(MultiSmsSender.PARAM_ENTRY_ID): null;
|
||||
|
||||
Uri entryURI = intent.getData();
|
||||
String entryStr = entryURI.getLastPathSegment();
|
||||
entryId = Long.parseLong(entryStr);
|
||||
|
||||
//byte[] pdu = (byte[]) intent.getByteArrayExtra("pdu");
|
||||
//SmsMessage message = SmsMessage.createFromPdu(pdu);
|
||||
//int status = message.getStatus();
|
||||
|
@ -12,8 +12,10 @@ import android.app.PendingIntent;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.telephony.PhoneNumberUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
@ -42,6 +44,8 @@ public class MultiSmsSender extends Activity {
|
||||
public static final String PARAM_NUMBERS_LIST = "param number list";
|
||||
public static final String PARAM_FLUSH = "param flush";
|
||||
public static final String PARAM_ENTRY_ID = "entry_id";
|
||||
|
||||
public static final String DEBUG_TAG="MultiSmsSender";
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@ -136,12 +140,13 @@ public class MultiSmsSender extends Activity {
|
||||
|
||||
if (haveDeliveryReports) {
|
||||
long entryId = mDbHelper.createEntry(mDbHelper.nameFromNumber(newN), newN, deliveryId);
|
||||
Log.d(DEBUG_TAG, "entry is "+entryId);
|
||||
for (int j = 0; j < messageCount; j++) {
|
||||
|
||||
Intent intent = new Intent(MessageReceiver.MESSAGE_RECEIVED, null, this, MessageReceiver.class);
|
||||
intent.putExtra(PARAM_ENTRY_ID, entryId);
|
||||
Uri entryURI = Uri.withAppendedPath(EntryContentProvider.CONTENT_URI, ""+entryId);
|
||||
Intent intent = new Intent(MessageReceiver.MESSAGE_RECEIVED,entryURI, this, MessageReceiver.class);
|
||||
//intent.putExtra(PARAM_ENTRY_ID, entryId);
|
||||
deliveryIntents.add(PendingIntent.getBroadcast(
|
||||
this, 0, intent , PendingIntent.FLAG_UPDATE_CURRENT));
|
||||
this, 0, intent, 0));
|
||||
}
|
||||
|
||||
|
||||
|
@ -79,6 +79,7 @@ public class SelectGroupActivity extends ListActivity{
|
||||
protected void onListItemClick(ListView l, View v, int position, long id) {
|
||||
super.onListItemClick(l, v, position, id);
|
||||
Cursor phonesListCursor = mDbHelper.fetchPhonesFromGroup(id);
|
||||
startManagingCursor(phonesListCursor);
|
||||
int phoneNumberIdx = phonesListCursor.getColumnIndex(Phones.NUMBER);
|
||||
String[] res = new String[phonesListCursor.getCount()];
|
||||
phonesListCursor.moveToFirst();
|
||||
|
Loading…
Reference in New Issue
Block a user