Update attachments to use url.

This commit is contained in:
Mikunj
2019-10-17 10:39:59 +11:00
parent c8238df8ff
commit c6f5adb447
14 changed files with 55 additions and 27 deletions

View File

@@ -44,10 +44,13 @@ public abstract class Attachment {
@Nullable
private final StickerLocator stickerLocator;
// Loki
private final String url;
public Attachment(@NonNull String contentType, int transferState, long size, @Nullable String fileName,
@Nullable String location, @Nullable String key, @Nullable String relay,
@Nullable byte[] digest, @Nullable String fastPreflightId, boolean voiceNote,
int width, int height, boolean quote, @Nullable String caption, @Nullable StickerLocator stickerLocator)
int width, int height, boolean quote, @Nullable String caption, @Nullable StickerLocator stickerLocator, String url)
{
this.contentType = contentType;
this.transferState = transferState;
@@ -64,6 +67,7 @@ public abstract class Attachment {
this.quote = quote;
this.stickerLocator = stickerLocator;
this.caption = caption;
this.url = url;
}
@Nullable
@@ -147,4 +151,6 @@ public abstract class Attachment {
public @Nullable String getCaption() {
return caption;
}
public String getUrl() { return url; }
}

View File

@@ -19,9 +19,9 @@ public class DatabaseAttachment extends Attachment {
String fileName, String location, String key, String relay,
byte[] digest, String fastPreflightId, boolean voiceNote,
int width, int height, boolean quote, @Nullable String caption,
@Nullable StickerLocator stickerLocator)
@Nullable StickerLocator stickerLocator, String url)
{
super(contentType, transferProgress, size, fileName, location, key, relay, digest, fastPreflightId, voiceNote, width, height, quote, caption, stickerLocator);
super(contentType, transferProgress, size, fileName, location, key, relay, digest, fastPreflightId, voiceNote, width, height, quote, caption, stickerLocator, url);
this.attachmentId = attachmentId;
this.hasData = hasData;
this.hasThumbnail = hasThumbnail;

View File

@@ -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, null, null, false, 0, 0, false, null, null);
super("application/mms", getTransferStateFromStatus(status), size, null, null, null, null, null, null, false, 0, 0, false, null, null, "");
}
@Nullable

View File

@@ -20,9 +20,9 @@ public class PointerAttachment extends Attachment {
@Nullable String fileName, @NonNull String location,
@Nullable String key, @Nullable String relay,
@Nullable byte[] digest, @Nullable String fastPreflightId, boolean voiceNote,
int width, int height, @Nullable String caption, @Nullable StickerLocator stickerLocator)
int width, int height, @Nullable String caption, @Nullable StickerLocator stickerLocator, String url)
{
super(contentType, transferState, size, fileName, location, key, relay, digest, fastPreflightId, voiceNote, width, height, false, caption, stickerLocator);
super(contentType, transferState, size, fileName, location, key, relay, digest, fastPreflightId, voiceNote, width, height, false, caption, stickerLocator, url);
}
@Nullable
@@ -99,7 +99,8 @@ public class PointerAttachment extends Attachment {
pointer.get().asPointer().getWidth(),
pointer.get().asPointer().getHeight(),
pointer.get().asPointer().getCaption().orNull(),
stickerLocator));
stickerLocator,
pointer.get().asPointer().getUrl()));
}
@@ -119,6 +120,7 @@ public class PointerAttachment extends Attachment {
thumbnail != null ? thumbnail.asPointer().getWidth() : 0,
thumbnail != null ? thumbnail.asPointer().getHeight() : 0,
thumbnail != null ? thumbnail.asPointer().getCaption().orNull() : null,
null));
null,
thumbnail != null ? thumbnail.asPointer().getUrl() : ""));
}
}

View File

@@ -23,7 +23,7 @@ public class UriAttachment extends Attachment {
@Nullable String fileName, @Nullable String fastPreflightId,
boolean voiceNote, boolean quote, @Nullable String caption, @Nullable StickerLocator stickerLocator)
{
super(contentType, transferState, size, fileName, null, null, null, null, fastPreflightId, voiceNote, width, height, quote, caption, stickerLocator);
super(contentType, transferState, size, fileName, null, null, null, null, fastPreflightId, voiceNote, width, height, quote, caption, stickerLocator, "");
this.dataUri = dataUri;
this.thumbnailUri = thumbnailUri;
}