2015-10-13 01:25:05 +00:00
|
|
|
package org.thoughtcrime.securesms.attachments;
|
|
|
|
|
|
|
|
import android.net.Uri;
|
2016-12-11 21:37:27 +00:00
|
|
|
import android.support.annotation.Nullable;
|
2015-10-13 01:25:05 +00:00
|
|
|
|
|
|
|
import org.thoughtcrime.securesms.mms.PartAuthority;
|
2019-04-17 14:21:30 +00:00
|
|
|
import org.thoughtcrime.securesms.stickers.StickerLocator;
|
2015-10-13 01:25:05 +00:00
|
|
|
|
|
|
|
public class DatabaseAttachment extends Attachment {
|
|
|
|
|
|
|
|
private final AttachmentId attachmentId;
|
|
|
|
private final long mmsId;
|
|
|
|
private final boolean hasData;
|
2016-12-11 21:37:27 +00:00
|
|
|
private final boolean hasThumbnail;
|
2015-10-13 01:25:05 +00:00
|
|
|
|
2016-12-11 21:37:27 +00:00
|
|
|
public DatabaseAttachment(AttachmentId attachmentId, long mmsId,
|
|
|
|
boolean hasData, boolean hasThumbnail,
|
2015-10-13 01:25:05 +00:00
|
|
|
String contentType, int transferProgress, long size,
|
2017-03-28 19:05:30 +00:00
|
|
|
String fileName, String location, String key, String relay,
|
2018-03-18 23:04:33 +00:00
|
|
|
byte[] digest, String fastPreflightId, boolean voiceNote,
|
2019-04-17 14:21:30 +00:00
|
|
|
int width, int height, boolean quote, @Nullable String caption,
|
2019-10-16 23:39:59 +00:00
|
|
|
@Nullable StickerLocator stickerLocator, String url)
|
2015-10-13 01:25:05 +00:00
|
|
|
{
|
2019-10-16 23:39:59 +00:00
|
|
|
super(contentType, transferProgress, size, fileName, location, key, relay, digest, fastPreflightId, voiceNote, width, height, quote, caption, stickerLocator, url);
|
2015-10-13 01:25:05 +00:00
|
|
|
this.attachmentId = attachmentId;
|
|
|
|
this.hasData = hasData;
|
2016-12-11 21:37:27 +00:00
|
|
|
this.hasThumbnail = hasThumbnail;
|
2015-10-13 01:25:05 +00:00
|
|
|
this.mmsId = mmsId;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-12-11 21:37:27 +00:00
|
|
|
@Nullable
|
2015-10-13 01:25:05 +00:00
|
|
|
public Uri getDataUri() {
|
2016-12-11 21:37:27 +00:00
|
|
|
if (hasData) {
|
|
|
|
return PartAuthority.getAttachmentDataUri(attachmentId);
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
2015-10-13 01:25:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-12-11 21:37:27 +00:00
|
|
|
@Nullable
|
2015-10-13 01:25:05 +00:00
|
|
|
public Uri getThumbnailUri() {
|
2016-12-11 21:37:27 +00:00
|
|
|
if (hasThumbnail) {
|
|
|
|
return PartAuthority.getAttachmentThumbnailUri(attachmentId);
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
2015-10-13 01:25:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public AttachmentId getAttachmentId() {
|
|
|
|
return attachmentId;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean equals(Object other) {
|
|
|
|
return other != null &&
|
|
|
|
other instanceof DatabaseAttachment &&
|
|
|
|
((DatabaseAttachment) other).attachmentId.equals(this.attachmentId);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int hashCode() {
|
|
|
|
return attachmentId.hashCode();
|
|
|
|
}
|
|
|
|
|
|
|
|
public long getMmsId() {
|
|
|
|
return mmsId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean hasData() {
|
|
|
|
return hasData;
|
|
|
|
}
|
2016-12-11 21:37:27 +00:00
|
|
|
|
|
|
|
public boolean hasThumbnail() {
|
|
|
|
return hasThumbnail;
|
|
|
|
}
|
2015-10-13 01:25:05 +00:00
|
|
|
}
|