mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-23 06:08:52 +01:00
Formatting for PduPersister
This commit is contained in:
@@ -38,7 +38,6 @@ import android.provider.Telephony.Threads;
|
|||||||
import android.telephony.PhoneNumberUtils;
|
import android.telephony.PhoneNumberUtils;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import com.google.android.mms.ContentType;
|
import com.google.android.mms.ContentType;
|
||||||
import com.google.android.mms.InvalidHeaderValueException;
|
import com.google.android.mms.InvalidHeaderValueException;
|
||||||
import com.google.android.mms.MmsException;
|
import com.google.android.mms.MmsException;
|
||||||
@@ -290,7 +289,9 @@ public class PduPersister {
|
|||||||
.getSystemService(Context.TELEPHONY_SERVICE);
|
.getSystemService(Context.TELEPHONY_SERVICE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get(or create if not exist) an instance of PduPersister */
|
/**
|
||||||
|
* Get(or create if not exist) an instance of PduPersister
|
||||||
|
*/
|
||||||
public static PduPersister getPduPersister(Context context) {
|
public static PduPersister getPduPersister(Context context) {
|
||||||
if ((sPersister == null)) {
|
if ((sPersister == null)) {
|
||||||
sPersister = new PduPersister(context);
|
sPersister = new PduPersister(context);
|
||||||
@@ -960,7 +961,7 @@ public class PduPersister {
|
|||||||
* content://media/<table_name>/<row_index> (or)
|
* content://media/<table_name>/<row_index> (or)
|
||||||
* file://sdcard/test.mp4
|
* file://sdcard/test.mp4
|
||||||
* http://test.com/test.mp4
|
* http://test.com/test.mp4
|
||||||
*
|
* <p>
|
||||||
* Here <table_name> shall be "video" or "audio" or "images"
|
* Here <table_name> shall be "video" or "audio" or "images"
|
||||||
* <row_index> the index of the content in given table
|
* <row_index> the index of the content in given table
|
||||||
*/
|
*/
|
||||||
@@ -1274,17 +1275,19 @@ public class PduPersister {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public Uri persist(GenericPdu pdu, Uri uri, boolean createThreadId, boolean groupMmsEnabled,
|
public Uri persist(GenericPdu pdu, Uri uri, boolean createThreadId, boolean groupMmsEnabled,
|
||||||
HashMap<Uri, InputStream> preOpenedFiles)
|
HashMap<Uri, InputStream> preOpenedFiles) throws MmsException {
|
||||||
throws MmsException {
|
|
||||||
if (uri == null) {
|
if (uri == null) {
|
||||||
throw new MmsException("Uri may not be null.");
|
throw new MmsException("Uri may not be null.");
|
||||||
}
|
}
|
||||||
|
|
||||||
long msgId = -1;
|
long msgId = -1;
|
||||||
try {
|
try {
|
||||||
msgId = ContentUris.parseId(uri);
|
msgId = ContentUris.parseId(uri);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
// the uri ends with "inbox" or something else like that
|
// the uri ends with "inbox" or something else like that
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean existingUri = msgId != -1;
|
boolean existingUri = msgId != -1;
|
||||||
|
|
||||||
if (!existingUri && MESSAGE_BOX_MAP.get(uri) == null) {
|
if (!existingUri && MESSAGE_BOX_MAP.get(uri) == null) {
|
||||||
|
|||||||
@@ -75,8 +75,6 @@ public class Transaction {
|
|||||||
public static Settings settings;
|
public static Settings settings;
|
||||||
private Context context;
|
private Context context;
|
||||||
|
|
||||||
private Intent explicitSentMmsReceiver;
|
|
||||||
|
|
||||||
private boolean saveMessage = true;
|
private boolean saveMessage = true;
|
||||||
|
|
||||||
public String SMS_SENT = ".SMS_SENT";
|
public String SMS_SENT = ".SMS_SENT";
|
||||||
@@ -381,9 +379,8 @@ public class Transaction {
|
|||||||
data.add(part);
|
data.add(part);
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.v(TAG, "using lollipop method for sending sms");
|
Log.v(TAG, "sending mms");
|
||||||
Log.v(TAG, "using system method for sending");
|
sendMmsThroughSystem(context, subject, data, addresses);
|
||||||
sendMmsThroughSystem(context, subject, data, addresses, explicitSentMmsReceiver);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MessageInfo getBytes(Context context, boolean saveMessage, String[] recipients, MMSPart[] parts,
|
public static MessageInfo getBytes(Context context, boolean saveMessage, String[] recipients, MMSPart[] parts,
|
||||||
@@ -509,8 +506,7 @@ public class Transaction {
|
|||||||
public static final long DEFAULT_EXPIRY_TIME = 7 * 24 * 60 * 60;
|
public static final long DEFAULT_EXPIRY_TIME = 7 * 24 * 60 * 60;
|
||||||
public static final int DEFAULT_PRIORITY = PduHeaders.PRIORITY_NORMAL;
|
public static final int DEFAULT_PRIORITY = PduHeaders.PRIORITY_NORMAL;
|
||||||
|
|
||||||
private static void sendMmsThroughSystem(Context context, String subject, List<MMSPart> parts, String[] addresses,
|
private static void sendMmsThroughSystem(Context context, String subject, List<MMSPart> parts, String[] addresses) {
|
||||||
Intent explicitSentMmsReceiver) {
|
|
||||||
try {
|
try {
|
||||||
final String fileName = "send." + String.valueOf(Math.abs(new Random().nextLong())) + ".dat";
|
final String fileName = "send." + String.valueOf(Math.abs(new Random().nextLong())) + ".dat";
|
||||||
File mSendFile = new File(context.getCacheDir(), fileName);
|
File mSendFile = new File(context.getCacheDir(), fileName);
|
||||||
@@ -520,13 +516,8 @@ public class Transaction {
|
|||||||
Uri messageUri = persister.persist(sendReq, Uri.parse("content://mms/outbox"),
|
Uri messageUri = persister.persist(sendReq, Uri.parse("content://mms/outbox"),
|
||||||
true, true, null);
|
true, true, null);
|
||||||
|
|
||||||
Intent intent;
|
Intent intent = new Intent(MmsSentReceiver.MMS_SENT);
|
||||||
if (explicitSentMmsReceiver == null) {
|
|
||||||
intent = new Intent(MmsSentReceiver.MMS_SENT);
|
|
||||||
BroadcastUtils.addClassName(context, intent, MmsSentReceiver.MMS_SENT);
|
BroadcastUtils.addClassName(context, intent, MmsSentReceiver.MMS_SENT);
|
||||||
} else {
|
|
||||||
intent = explicitSentMmsReceiver;
|
|
||||||
}
|
|
||||||
|
|
||||||
intent.putExtra(MmsSentReceiver.EXTRA_CONTENT_URI, messageUri.toString());
|
intent.putExtra(MmsSentReceiver.EXTRA_CONTENT_URI, messageUri.toString());
|
||||||
intent.putExtra(MmsSentReceiver.EXTRA_FILE_PATH, mSendFile.getPath());
|
intent.putExtra(MmsSentReceiver.EXTRA_FILE_PATH, mSendFile.getPath());
|
||||||
|
|||||||
Reference in New Issue
Block a user