session-android/src/org/thoughtcrime/securesms/mms/OutgoingMediaMessage.java
Moxie Marlinspike 6da86e482d Support for dual-sim SMS/MMS functionality
Allow source selection for sending SMS/MMS, and display the
SIM that received SMS/MMS.

Fixes #555
Closes #5199
// FREEBIE
2016-02-09 16:53:15 -08:00

92 lines
2.5 KiB
Java

package org.thoughtcrime.securesms.mms;
import android.text.TextUtils;
import org.thoughtcrime.securesms.attachments.Attachment;
import org.thoughtcrime.securesms.recipients.Recipients;
import java.util.List;
public class OutgoingMediaMessage {
private final Recipients recipients;
protected final String body;
protected final List<Attachment> attachments;
private final long sentTimeMillis;
private final int distributionType;
private final int subscriptionId;
public OutgoingMediaMessage(Recipients recipients, String message,
List<Attachment> attachments, long sentTimeMillis,
int subscriptionId,
int distributionType)
{
this.recipients = recipients;
this.body = message;
this.sentTimeMillis = sentTimeMillis;
this.distributionType = distributionType;
this.attachments = attachments;
this.subscriptionId = subscriptionId;
}
public OutgoingMediaMessage(Recipients recipients, SlideDeck slideDeck, String message, long sentTimeMillis, int subscriptionId, int distributionType)
{
this(recipients,
buildMessage(slideDeck, message),
slideDeck.asAttachments(),
sentTimeMillis, subscriptionId,
distributionType);
}
public OutgoingMediaMessage(OutgoingMediaMessage that) {
this.recipients = that.getRecipients();
this.body = that.body;
this.distributionType = that.distributionType;
this.attachments = that.attachments;
this.sentTimeMillis = that.sentTimeMillis;
this.subscriptionId = that.subscriptionId;
}
public Recipients getRecipients() {
return recipients;
}
public String getBody() {
return body;
}
public List<Attachment> getAttachments() {
return attachments;
}
public int getDistributionType() {
return distributionType;
}
public boolean isSecure() {
return false;
}
public boolean isGroup() {
return false;
}
public long getSentTimeMillis() {
return sentTimeMillis;
}
public int getSubscriptionId() {
return subscriptionId;
}
private static String buildMessage(SlideDeck slideDeck, String message) {
if (!TextUtils.isEmpty(message) && !TextUtils.isEmpty(slideDeck.getBody())) {
return slideDeck.getBody() + "\n\n" + message;
} else if (!TextUtils.isEmpty(message)) {
return message;
} else {
return slideDeck.getBody();
}
}
}