mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-03-02 15:36:32 +00:00
Allow source selection for sending SMS/MMS, and display the SIM that received SMS/MMS. Fixes #555 Closes #5199 // FREEBIE
68 lines
1.9 KiB
Java
68 lines
1.9 KiB
Java
package org.thoughtcrime.securesms.sms;
|
|
|
|
import org.thoughtcrime.securesms.database.model.SmsMessageRecord;
|
|
import org.thoughtcrime.securesms.recipients.Recipients;
|
|
|
|
public class OutgoingTextMessage {
|
|
|
|
private final Recipients recipients;
|
|
private final String message;
|
|
private final int subscriptionId;
|
|
|
|
public OutgoingTextMessage(Recipients recipients, String message, int subscriptionId) {
|
|
this.recipients = recipients;
|
|
this.message = message;
|
|
this.subscriptionId = subscriptionId;
|
|
}
|
|
|
|
protected OutgoingTextMessage(OutgoingTextMessage base, String body) {
|
|
this.recipients = base.getRecipients();
|
|
this.subscriptionId = base.getSubscriptionId();
|
|
this.message = body;
|
|
}
|
|
|
|
public int getSubscriptionId() {
|
|
return subscriptionId;
|
|
}
|
|
|
|
public String getMessageBody() {
|
|
return message;
|
|
}
|
|
|
|
public Recipients getRecipients() {
|
|
return recipients;
|
|
}
|
|
|
|
public boolean isKeyExchange() {
|
|
return false;
|
|
}
|
|
|
|
public boolean isSecureMessage() {
|
|
return false;
|
|
}
|
|
|
|
public boolean isEndSession() {
|
|
return false;
|
|
}
|
|
|
|
public boolean isPreKeyBundle() {
|
|
return false;
|
|
}
|
|
|
|
public static OutgoingTextMessage from(SmsMessageRecord record) {
|
|
if (record.isSecure()) {
|
|
return new OutgoingEncryptedMessage(record.getRecipients(), record.getBody().getBody());
|
|
} else if (record.isKeyExchange()) {
|
|
return new OutgoingKeyExchangeMessage(record.getRecipients(), record.getBody().getBody());
|
|
} else if (record.isEndSession()) {
|
|
return new OutgoingEndSessionMessage(new OutgoingTextMessage(record.getRecipients(), record.getBody().getBody(), -1));
|
|
} else {
|
|
return new OutgoingTextMessage(record.getRecipients(), record.getBody().getBody(), record.getSubscriptionId());
|
|
}
|
|
}
|
|
|
|
public OutgoingTextMessage withBody(String body) {
|
|
return new OutgoingTextMessage(this, body);
|
|
}
|
|
}
|