mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 09:20:19 +01:00
Add UI components for Release Channel.
This commit is contained in:
@@ -1,200 +0,0 @@
|
||||
package org.thoughtcrime.securesms.mms;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
||||
import org.thoughtcrime.securesms.attachments.PointerAttachment;
|
||||
import org.thoughtcrime.securesms.contactshare.Contact;
|
||||
import org.thoughtcrime.securesms.database.model.Mention;
|
||||
import org.thoughtcrime.securesms.groups.GroupId;
|
||||
import org.thoughtcrime.securesms.linkpreview.LinkPreview;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
import org.thoughtcrime.securesms.util.GroupUtil;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceAttachment;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceGroupContext;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class IncomingMediaMessage {
|
||||
|
||||
private final RecipientId from;
|
||||
private final GroupId groupId;
|
||||
private final String body;
|
||||
private final boolean push;
|
||||
private final long sentTimeMillis;
|
||||
private final long serverTimeMillis;
|
||||
private final long receivedTimeMillis;
|
||||
private final int subscriptionId;
|
||||
private final long expiresIn;
|
||||
private final boolean expirationUpdate;
|
||||
private final QuoteModel quote;
|
||||
private final boolean unidentified;
|
||||
private final boolean viewOnce;
|
||||
private final String serverGuid;
|
||||
|
||||
private final List<Attachment> attachments = new LinkedList<>();
|
||||
private final List<Contact> sharedContacts = new LinkedList<>();
|
||||
private final List<LinkPreview> linkPreviews = new LinkedList<>();
|
||||
private final List<Mention> mentions = new LinkedList<>();
|
||||
|
||||
public IncomingMediaMessage(@NonNull RecipientId from,
|
||||
Optional<GroupId> groupId,
|
||||
String body,
|
||||
long sentTimeMillis,
|
||||
long serverTimeMillis,
|
||||
long receivedTimeMillis,
|
||||
List<Attachment> attachments,
|
||||
int subscriptionId,
|
||||
long expiresIn,
|
||||
boolean expirationUpdate,
|
||||
boolean viewOnce,
|
||||
boolean unidentified,
|
||||
Optional<List<Contact>> sharedContacts)
|
||||
{
|
||||
this.from = from;
|
||||
this.groupId = groupId.orNull();
|
||||
this.sentTimeMillis = sentTimeMillis;
|
||||
this.serverTimeMillis = serverTimeMillis;
|
||||
this.receivedTimeMillis = receivedTimeMillis;
|
||||
this.body = body;
|
||||
this.push = false;
|
||||
this.subscriptionId = subscriptionId;
|
||||
this.expiresIn = expiresIn;
|
||||
this.expirationUpdate = expirationUpdate;
|
||||
this.viewOnce = viewOnce;
|
||||
this.quote = null;
|
||||
this.unidentified = unidentified;
|
||||
this.serverGuid = null;
|
||||
|
||||
this.attachments.addAll(attachments);
|
||||
this.sharedContacts.addAll(sharedContacts.or(Collections.emptyList()));
|
||||
|
||||
}
|
||||
|
||||
public IncomingMediaMessage(@NonNull RecipientId from,
|
||||
long sentTimeMillis,
|
||||
long serverTimeMillis,
|
||||
long receivedTimeMillis,
|
||||
int subscriptionId,
|
||||
long expiresIn,
|
||||
boolean expirationUpdate,
|
||||
boolean viewOnce,
|
||||
boolean unidentified,
|
||||
Optional<String> body,
|
||||
Optional<SignalServiceGroupContext> group,
|
||||
Optional<List<SignalServiceAttachment>> attachments,
|
||||
Optional<QuoteModel> quote,
|
||||
Optional<List<Contact>> sharedContacts,
|
||||
Optional<List<LinkPreview>> linkPreviews,
|
||||
Optional<List<Mention>> mentions,
|
||||
Optional<Attachment> sticker,
|
||||
@Nullable String serverGuid)
|
||||
{
|
||||
this.push = true;
|
||||
this.from = from;
|
||||
this.sentTimeMillis = sentTimeMillis;
|
||||
this.serverTimeMillis = serverTimeMillis;
|
||||
this.receivedTimeMillis = receivedTimeMillis;
|
||||
this.body = body.orNull();
|
||||
this.subscriptionId = subscriptionId;
|
||||
this.expiresIn = expiresIn;
|
||||
this.expirationUpdate = expirationUpdate;
|
||||
this.viewOnce = viewOnce;
|
||||
this.quote = quote.orNull();
|
||||
this.unidentified = unidentified;
|
||||
|
||||
if (group.isPresent()) this.groupId = GroupUtil.idFromGroupContextOrThrow(group.get());
|
||||
else this.groupId = null;
|
||||
|
||||
this.attachments.addAll(PointerAttachment.forPointers(attachments));
|
||||
this.sharedContacts.addAll(sharedContacts.or(Collections.emptyList()));
|
||||
this.linkPreviews.addAll(linkPreviews.or(Collections.emptyList()));
|
||||
this.mentions.addAll(mentions.or(Collections.emptyList()));
|
||||
|
||||
if (sticker.isPresent()) {
|
||||
this.attachments.add(sticker.get());
|
||||
}
|
||||
|
||||
this.serverGuid = serverGuid;
|
||||
}
|
||||
|
||||
public int getSubscriptionId() {
|
||||
return subscriptionId;
|
||||
}
|
||||
|
||||
public String getBody() {
|
||||
return body;
|
||||
}
|
||||
|
||||
public List<Attachment> getAttachments() {
|
||||
return attachments;
|
||||
}
|
||||
|
||||
public @NonNull RecipientId getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
public GroupId getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public boolean isPushMessage() {
|
||||
return push;
|
||||
}
|
||||
|
||||
public boolean isExpirationUpdate() {
|
||||
return expirationUpdate;
|
||||
}
|
||||
|
||||
public long getSentTimeMillis() {
|
||||
return sentTimeMillis;
|
||||
}
|
||||
|
||||
public long getServerTimeMillis() {
|
||||
return serverTimeMillis;
|
||||
}
|
||||
|
||||
public long getReceivedTimeMillis() {
|
||||
return receivedTimeMillis;
|
||||
}
|
||||
|
||||
public long getExpiresIn() {
|
||||
return expiresIn;
|
||||
}
|
||||
|
||||
public boolean isViewOnce() {
|
||||
return viewOnce;
|
||||
}
|
||||
|
||||
public boolean isGroupMessage() {
|
||||
return groupId != null;
|
||||
}
|
||||
|
||||
public QuoteModel getQuote() {
|
||||
return quote;
|
||||
}
|
||||
|
||||
public List<Contact> getSharedContacts() {
|
||||
return sharedContacts;
|
||||
}
|
||||
|
||||
public List<LinkPreview> getLinkPreviews() {
|
||||
return linkPreviews;
|
||||
}
|
||||
|
||||
public @NonNull List<Mention> getMentions() {
|
||||
return mentions;
|
||||
}
|
||||
|
||||
public boolean isUnidentified() {
|
||||
return unidentified;
|
||||
}
|
||||
|
||||
public @Nullable String getServerGuid() {
|
||||
return serverGuid;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package org.thoughtcrime.securesms.mms
|
||||
|
||||
import org.thoughtcrime.securesms.attachments.Attachment
|
||||
import org.thoughtcrime.securesms.attachments.PointerAttachment
|
||||
import org.thoughtcrime.securesms.contactshare.Contact
|
||||
import org.thoughtcrime.securesms.database.model.Mention
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.BodyRangeList
|
||||
import org.thoughtcrime.securesms.groups.GroupId
|
||||
import org.thoughtcrime.securesms.linkpreview.LinkPreview
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
import org.thoughtcrime.securesms.util.GroupUtil
|
||||
import org.whispersystems.libsignal.util.guava.Optional
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceAttachment
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceGroupContext
|
||||
|
||||
class IncomingMediaMessage(
|
||||
val from: RecipientId,
|
||||
val groupId: GroupId? = null,
|
||||
val body: String? = null,
|
||||
val isPushMessage: Boolean = false,
|
||||
val sentTimeMillis: Long,
|
||||
val serverTimeMillis: Long,
|
||||
val receivedTimeMillis: Long,
|
||||
val subscriptionId: Int = -1,
|
||||
val expiresIn: Long = 0,
|
||||
val isExpirationUpdate: Boolean = false,
|
||||
val quote: QuoteModel? = null,
|
||||
val isUnidentified: Boolean = false,
|
||||
val isViewOnce: Boolean = false,
|
||||
val serverGuid: String? = null,
|
||||
val messageRanges: BodyRangeList? = null,
|
||||
attachments: List<Attachment> = emptyList(),
|
||||
sharedContacts: List<Contact> = emptyList(),
|
||||
linkPreviews: List<LinkPreview> = emptyList(),
|
||||
mentions: List<Mention> = emptyList()
|
||||
) {
|
||||
|
||||
val attachments: List<Attachment> = ArrayList(attachments)
|
||||
val sharedContacts: List<Contact> = ArrayList(sharedContacts)
|
||||
val linkPreviews: List<LinkPreview> = ArrayList(linkPreviews)
|
||||
val mentions: List<Mention> = ArrayList(mentions)
|
||||
|
||||
val isGroupMessage: Boolean = groupId != null
|
||||
|
||||
constructor(
|
||||
from: RecipientId,
|
||||
groupId: Optional<GroupId>,
|
||||
body: String,
|
||||
sentTimeMillis: Long,
|
||||
serverTimeMillis: Long,
|
||||
receivedTimeMillis: Long,
|
||||
attachments: List<Attachment>,
|
||||
subscriptionId: Int,
|
||||
expiresIn: Long,
|
||||
expirationUpdate: Boolean,
|
||||
viewOnce: Boolean,
|
||||
unidentified: Boolean,
|
||||
sharedContacts: Optional<List<Contact>>
|
||||
) : this(
|
||||
from = from,
|
||||
groupId = groupId.orNull(),
|
||||
body = body,
|
||||
isPushMessage = false,
|
||||
sentTimeMillis = sentTimeMillis,
|
||||
serverTimeMillis = serverTimeMillis,
|
||||
receivedTimeMillis = receivedTimeMillis,
|
||||
subscriptionId = subscriptionId,
|
||||
expiresIn = expiresIn,
|
||||
isExpirationUpdate = expirationUpdate,
|
||||
quote = null,
|
||||
isUnidentified = unidentified,
|
||||
isViewOnce = viewOnce,
|
||||
serverGuid = null,
|
||||
attachments = ArrayList(attachments),
|
||||
sharedContacts = ArrayList(sharedContacts.or(emptyList()))
|
||||
)
|
||||
|
||||
constructor(
|
||||
from: RecipientId,
|
||||
sentTimeMillis: Long,
|
||||
serverTimeMillis: Long,
|
||||
receivedTimeMillis: Long,
|
||||
subscriptionId: Int,
|
||||
expiresIn: Long,
|
||||
expirationUpdate: Boolean,
|
||||
viewOnce: Boolean,
|
||||
unidentified: Boolean,
|
||||
body: Optional<String>,
|
||||
group: Optional<SignalServiceGroupContext>,
|
||||
attachments: Optional<List<SignalServiceAttachment>>,
|
||||
quote: Optional<QuoteModel>,
|
||||
sharedContacts: Optional<List<Contact>>,
|
||||
linkPreviews: Optional<List<LinkPreview>>,
|
||||
mentions: Optional<List<Mention>>,
|
||||
sticker: Optional<Attachment>,
|
||||
serverGuid: String?
|
||||
) : this(
|
||||
from = from,
|
||||
groupId = if (group.isPresent) GroupUtil.idFromGroupContextOrThrow(group.get()) else null,
|
||||
body = body.orNull(),
|
||||
isPushMessage = true,
|
||||
sentTimeMillis = sentTimeMillis,
|
||||
serverTimeMillis = serverTimeMillis,
|
||||
receivedTimeMillis = receivedTimeMillis,
|
||||
subscriptionId = subscriptionId,
|
||||
expiresIn = expiresIn,
|
||||
isExpirationUpdate = expirationUpdate,
|
||||
quote = quote.orNull(),
|
||||
isUnidentified = unidentified,
|
||||
isViewOnce = viewOnce,
|
||||
serverGuid = serverGuid,
|
||||
attachments = PointerAttachment.forPointers(attachments).apply { if (sticker.isPresent) add(sticker.get()) },
|
||||
sharedContacts = sharedContacts.or(emptyList()),
|
||||
linkPreviews = linkPreviews.or(emptyList()),
|
||||
mentions = mentions.or(emptyList())
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user