mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-05-01 14:13:22 +01:00
Support for receiving arbitrary attachment types
// FREEBIE
This commit is contained in:
@@ -13,6 +13,9 @@ public abstract class Attachment {
|
||||
private final int transferState;
|
||||
private final long size;
|
||||
|
||||
@Nullable
|
||||
private final String fileName;
|
||||
|
||||
@Nullable
|
||||
private final String location;
|
||||
|
||||
@@ -25,13 +28,14 @@ public abstract class Attachment {
|
||||
@Nullable
|
||||
private final byte[] digest;
|
||||
|
||||
public Attachment(@NonNull String contentType, int transferState, long size,
|
||||
public Attachment(@NonNull String contentType, int transferState, long size, @Nullable String fileName,
|
||||
@Nullable String location, @Nullable String key, @Nullable String relay,
|
||||
@Nullable byte[] digest)
|
||||
{
|
||||
this.contentType = contentType;
|
||||
this.transferState = transferState;
|
||||
this.size = size;
|
||||
this.fileName = fileName;
|
||||
this.location = location;
|
||||
this.key = key;
|
||||
this.relay = relay;
|
||||
@@ -57,6 +61,11 @@ public abstract class Attachment {
|
||||
return size;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public String getContentType() {
|
||||
return contentType;
|
||||
|
||||
@@ -15,9 +15,10 @@ public class DatabaseAttachment extends Attachment {
|
||||
public DatabaseAttachment(AttachmentId attachmentId, long mmsId,
|
||||
boolean hasData, boolean hasThumbnail,
|
||||
String contentType, int transferProgress, long size,
|
||||
String location, String key, String relay, byte[] digest)
|
||||
String fileName, String location, String key, String relay,
|
||||
byte[] digest)
|
||||
{
|
||||
super(contentType, transferProgress, size, location, key, relay, digest);
|
||||
super(contentType, transferProgress, size, fileName, location, key, relay, digest);
|
||||
this.attachmentId = attachmentId;
|
||||
this.hasData = hasData;
|
||||
this.hasThumbnail = hasThumbnail;
|
||||
|
||||
@@ -10,7 +10,7 @@ import org.thoughtcrime.securesms.database.MmsDatabase;
|
||||
public class MmsNotificationAttachment extends Attachment {
|
||||
|
||||
public MmsNotificationAttachment(int status, long size) {
|
||||
super("application/mms", getTransferStateFromStatus(status), size, null, null, null, null);
|
||||
super("application/mms", getTransferStateFromStatus(status), size, null, null, null, null, null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -16,10 +16,11 @@ import java.util.List;
|
||||
public class PointerAttachment extends Attachment {
|
||||
|
||||
public PointerAttachment(@NonNull String contentType, int transferState, long size,
|
||||
@NonNull String location, @NonNull String key, @NonNull String relay,
|
||||
@Nullable String fileName, @NonNull String location,
|
||||
@NonNull String key, @NonNull String relay,
|
||||
@Nullable byte[] digest)
|
||||
{
|
||||
super(contentType, transferState, size, location, key, relay, digest);
|
||||
super(contentType, transferState, size, fileName, location, key, relay, digest);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -45,6 +46,7 @@ public class PointerAttachment extends Attachment {
|
||||
results.add(new PointerAttachment(pointer.getContentType(),
|
||||
AttachmentDatabase.TRANSFER_PROGRESS_AUTO_PENDING,
|
||||
pointer.asPointer().getSize().or(0),
|
||||
pointer.asPointer().getFileName().orNull(),
|
||||
String.valueOf(pointer.asPointer().getId()),
|
||||
encryptedKey, pointer.asPointer().getRelay().orNull(),
|
||||
pointer.asPointer().getDigest().orNull()));
|
||||
|
||||
@@ -9,14 +9,17 @@ public class UriAttachment extends Attachment {
|
||||
private final @NonNull Uri dataUri;
|
||||
private final @Nullable Uri thumbnailUri;
|
||||
|
||||
public UriAttachment(@NonNull Uri uri, @NonNull String contentType, int transferState, long size) {
|
||||
this(uri, uri, contentType, transferState, size);
|
||||
public UriAttachment(@NonNull Uri uri, @NonNull String contentType, int transferState, long size,
|
||||
@Nullable String fileName)
|
||||
{
|
||||
this(uri, uri, contentType, transferState, size, fileName);
|
||||
}
|
||||
|
||||
public UriAttachment(@NonNull Uri dataUri, @Nullable Uri thumbnailUri,
|
||||
@NonNull String contentType, int transferState, long size)
|
||||
@NonNull String contentType, int transferState, long size,
|
||||
@Nullable String fileName)
|
||||
{
|
||||
super(contentType, transferState, size, null, null, null, null);
|
||||
super(contentType, transferState, size, fileName, null, null, null, null);
|
||||
this.dataUri = dataUri;
|
||||
this.thumbnailUri = thumbnailUri;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user