Delivery intents *Should* be working but... ?? Implements a mySMSManger to use cupcake or newer version of SMSManager
This commit is contained in:
parent
5f29b32554
commit
6c373b51e5
@ -14,7 +14,11 @@
|
|||||||
<activity android:name="GroupEditActivity"></activity>
|
<activity android:name="GroupEditActivity"></activity>
|
||||||
<activity android:name="SelectDeliveryActivity"></activity>
|
<activity android:name="SelectDeliveryActivity"></activity>
|
||||||
<activity android:name="ListEntryActivity"></activity>
|
<activity android:name="ListEntryActivity"></activity>
|
||||||
<receiver android:name="MessageReceiver" android:exported="false" ></receiver>
|
<receiver android:name="MessageReceiver">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="com.openwide.android.mutliSmsSend.message_received"/>
|
||||||
|
</intent-filter>
|
||||||
|
</receiver>
|
||||||
</application>
|
</application>
|
||||||
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="4" />
|
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="4" />
|
||||||
<supports-screens android:smallScreens="true"
|
<supports-screens android:smallScreens="true"
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
<string name="remove">Supprimer</string>
|
<string name="remove">Supprimer</string>
|
||||||
<string name="add_group">Ajouter un groupe</string>
|
<string name="add_group">Ajouter un groupe</string>
|
||||||
<string name="delivery">Accusé de récéption</string>
|
<string name="delivery">Accusé de récéption</string>
|
||||||
|
<string name="nodelivery">Aucun accusé de récéption</string>
|
||||||
<string name="enabledelivery">Accusé de récéption</string>
|
<string name="enabledelivery">Accusé de récéption</string>
|
||||||
<string name="create_group">Créer un group</string>
|
<string name="create_group">Créer un group</string>
|
||||||
<string name="remove_group">Supprimer ce groupe</string>
|
<string name="remove_group">Supprimer ce groupe</string>
|
||||||
|
@ -6,6 +6,7 @@ import android.database.Cursor;
|
|||||||
import android.database.SQLException;
|
import android.database.SQLException;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
import android.database.sqlite.SQLiteOpenHelper;
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
|
import android.net.Uri;
|
||||||
import android.provider.Contacts.Phones;
|
import android.provider.Contacts.Phones;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
@ -236,13 +237,12 @@ public class DeliveryDbAdapter {
|
|||||||
|
|
||||||
|
|
||||||
public String nameFromNumber(String number) {
|
public String nameFromNumber(String number) {
|
||||||
//TODO
|
Uri contactUri = Uri.withAppendedPath(Phones.CONTENT_FILTER_URL, Uri.encode(number));
|
||||||
//Cursor c1 = mCtx.getContentResolver().query(Phones.CONTENT_URI, new String[] { Phones.NUMBER }, null, null, null);
|
Cursor c = mCtx.getContentResolver().query(contactUri, new String[] { Phones.DISPLAY_NAME }, null, null, null);
|
||||||
Cursor c = mCtx.getContentResolver().query(Phones.CONTENT_URI, new String[] { Phones.NAME }, Phones.NUMBER +"="+number, null, null);
|
|
||||||
if(c != null) {
|
if(c != null) {
|
||||||
c.moveToFirst();
|
c.moveToFirst();
|
||||||
if(c.isFirst()) {
|
if(c.isFirst()) {
|
||||||
return c.getString(c.getColumnIndex(Phones.NAME));
|
return c.getString(c.getColumnIndex(Phones.DISPLAY_NAME));
|
||||||
}else {
|
}else {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,8 @@ import android.app.ListActivity;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
@ -12,6 +14,7 @@ import android.widget.SimpleCursorAdapter;
|
|||||||
public class ListEntryActivity extends ListActivity {
|
public class ListEntryActivity extends ListActivity {
|
||||||
DeliveryDbAdapter mDbHelper;
|
DeliveryDbAdapter mDbHelper;
|
||||||
Long mDeliveryId;
|
Long mDeliveryId;
|
||||||
|
public static final int REFRESH_ID = 0;
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@ -53,6 +56,23 @@ public class ListEntryActivity extends ListActivity {
|
|||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
super.onCreateOptionsMenu(menu);
|
||||||
|
menu.add(0, REFRESH_ID,0, R.string.refresh);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onContextItemSelected(MenuItem item) {
|
||||||
|
switch(item.getItemId()) {
|
||||||
|
case REFRESH_ID:
|
||||||
|
fillData();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.onContextItemSelected(item);
|
||||||
|
}
|
||||||
|
|
||||||
private class EntryCursorAdapter extends SimpleCursorAdapter{
|
private class EntryCursorAdapter extends SimpleCursorAdapter{
|
||||||
Cursor c;
|
Cursor c;
|
||||||
int deliveredIdx;
|
int deliveredIdx;
|
||||||
@ -84,4 +104,6 @@ public class ListEntryActivity extends ListActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,16 +4,21 @@ import android.content.BroadcastReceiver;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
public class MessageReceiver extends BroadcastReceiver{
|
public class MessageReceiver extends BroadcastReceiver{
|
||||||
public static final String MESSAGE_RECEIVED = "com.openwide.android.mutliSmsSend.message_received";
|
public static final String MESSAGE_RECEIVED = "com.openwide.android.mutliSmsSend.message_received";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
Log.d("------------------", "WORKING :)!!!!");
|
||||||
if (MESSAGE_RECEIVED.equals(intent.getAction())) {
|
if (MESSAGE_RECEIVED.equals(intent.getAction())) {
|
||||||
Long entryId;
|
Long entryId;
|
||||||
Bundle extras = intent.getExtras();
|
Bundle extras = intent.getExtras();
|
||||||
entryId = extras != null ? extras.getLong(MultiSmsSender.PARAM_ENTRY_ID): null;
|
entryId = extras != null ? extras.getLong(MultiSmsSender.PARAM_ENTRY_ID): null;
|
||||||
|
//byte[] pdu = (byte[]) intent.getByteArrayExtra("pdu");
|
||||||
|
//SmsMessage message = SmsMessage.createFromPdu(pdu);
|
||||||
|
//int status = message.getStatus();
|
||||||
DeliveryDbAdapter mDbHelper = new DeliveryDbAdapter(context);
|
DeliveryDbAdapter mDbHelper = new DeliveryDbAdapter(context);
|
||||||
mDbHelper.open();
|
mDbHelper.open();
|
||||||
mDbHelper.setEntryDelivered(entryId);
|
mDbHelper.setEntryDelivered(entryId);
|
||||||
@ -23,7 +28,4 @@ public class MessageReceiver extends BroadcastReceiver{
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,12 +10,10 @@ import android.app.AlertDialog;
|
|||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.telephony.PhoneNumberUtils;
|
import android.telephony.PhoneNumberUtils;
|
||||||
import android.telephony.gsm.SmsManager;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -89,7 +87,7 @@ public class MultiSmsSender extends Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sendMessage() {
|
public void sendMessage() {
|
||||||
SmsManager manager = SmsManager.getDefault();
|
MySMSManager manager = MySMSManager.getInstance();
|
||||||
String message = mEditor.getText().toString();
|
String message = mEditor.getText().toString();
|
||||||
String[] numbers = mContacts.getText().toString().split(",");
|
String[] numbers = mContacts.getText().toString().split(",");
|
||||||
HashSet<String> allreadySend = new HashSet<String>();
|
HashSet<String> allreadySend = new HashSet<String>();
|
||||||
|
34
src/com/openwide/android/MySMSManager.java
Normal file
34
src/com/openwide/android/MySMSManager.java
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
package com.openwide.android;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import android.app.PendingIntent;
|
||||||
|
import android.os.Build;
|
||||||
|
|
||||||
|
public abstract class MySMSManager {
|
||||||
|
private static MySMSManager sInstance;
|
||||||
|
|
||||||
|
public static MySMSManager getInstance() {
|
||||||
|
if(sInstance == null) {
|
||||||
|
String className;
|
||||||
|
int sdkVersion = Integer.parseInt(Build.VERSION.SDK);
|
||||||
|
if (sdkVersion < Build.VERSION_CODES.DONUT) {
|
||||||
|
className = "com.openwide.android.MySMSManagerCupcake";
|
||||||
|
} else {
|
||||||
|
className = "com.openwide.android.MySMSManagerOther";
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Class<? extends MySMSManager> clazz =
|
||||||
|
Class.forName(className).asSubclass(MySMSManager.class);
|
||||||
|
sInstance = clazz.newInstance();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new IllegalStateException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract ArrayList<String> divideMessage(String text);
|
||||||
|
public abstract void sendMultipartTextMessage(String destinationAddress, String scAddress, ArrayList<String> parts, ArrayList<PendingIntent> sentIntents, ArrayList<PendingIntent> deliveryIntents );
|
||||||
|
|
||||||
|
}
|
29
src/com/openwide/android/MySMSManagerCupcake.java
Normal file
29
src/com/openwide/android/MySMSManagerCupcake.java
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
package com.openwide.android;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import android.app.PendingIntent;
|
||||||
|
import android.telephony.gsm.SmsManager;
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public class MySMSManagerCupcake extends MySMSManager {
|
||||||
|
|
||||||
|
SmsManager mManager;
|
||||||
|
public MySMSManagerCupcake() {
|
||||||
|
mManager = SmsManager.getDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ArrayList<String> divideMessage(String text) {
|
||||||
|
|
||||||
|
return mManager.divideMessage(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendMultipartTextMessage(String destinationAddress, String scAddress, ArrayList<String> parts, ArrayList<PendingIntent> sentIntents, ArrayList<PendingIntent> deliveryIntents ) {
|
||||||
|
mManager.sendMultipartTextMessage(destinationAddress, scAddress, parts, sentIntents, deliveryIntents);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
30
src/com/openwide/android/MySMSManagerOther.java
Normal file
30
src/com/openwide/android/MySMSManagerOther.java
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package com.openwide.android;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import android.app.PendingIntent;
|
||||||
|
import android.telephony.SmsManager;
|
||||||
|
|
||||||
|
public class MySMSManagerOther extends MySMSManager {
|
||||||
|
|
||||||
|
SmsManager mManager;
|
||||||
|
public MySMSManagerOther() {
|
||||||
|
mManager = SmsManager.getDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ArrayList<String> divideMessage(String text) {
|
||||||
|
|
||||||
|
return mManager.divideMessage(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendMultipartTextMessage(String destinationAddress,
|
||||||
|
String scAddress, ArrayList<String> parts,
|
||||||
|
ArrayList<PendingIntent> sentIntents,
|
||||||
|
ArrayList<PendingIntent> deliveryIntents) {
|
||||||
|
mManager.sendMultipartTextMessage(destinationAddress, scAddress, parts, sentIntents, deliveryIntents);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user