2015-10-12 18:25:05 -07:00
|
|
|
package org.thoughtcrime.securesms.attachments;
|
|
|
|
|
|
|
|
import android.net.Uri;
|
|
|
|
import android.support.annotation.NonNull;
|
|
|
|
import android.support.annotation.Nullable;
|
|
|
|
|
|
|
|
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
|
|
|
|
|
|
|
public abstract class Attachment {
|
|
|
|
|
|
|
|
@NonNull
|
|
|
|
private final String contentType;
|
|
|
|
private final int transferState;
|
|
|
|
private final long size;
|
|
|
|
|
2017-03-28 12:05:30 -07:00
|
|
|
@Nullable
|
|
|
|
private final String fileName;
|
|
|
|
|
2015-10-12 18:25:05 -07:00
|
|
|
@Nullable
|
|
|
|
private final String location;
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
private final String key;
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
private final String relay;
|
|
|
|
|
2017-02-26 10:06:27 -08:00
|
|
|
@Nullable
|
|
|
|
private final byte[] digest;
|
|
|
|
|
2017-04-22 16:29:26 -07:00
|
|
|
@Nullable
|
|
|
|
private final String fastPreflightId;
|
|
|
|
|
2017-05-11 22:46:35 -07:00
|
|
|
private final boolean voiceNote;
|
2018-03-18 16:04:33 -07:00
|
|
|
private final int width;
|
|
|
|
private final int height;
|
2017-05-11 22:46:35 -07:00
|
|
|
|
2018-02-07 14:01:37 -08:00
|
|
|
private final boolean quote;
|
|
|
|
|
2017-03-28 12:05:30 -07:00
|
|
|
public Attachment(@NonNull String contentType, int transferState, long size, @Nullable String fileName,
|
2017-02-26 10:06:27 -08:00
|
|
|
@Nullable String location, @Nullable String key, @Nullable String relay,
|
2018-03-18 16:04:33 -07:00
|
|
|
@Nullable byte[] digest, @Nullable String fastPreflightId, boolean voiceNote,
|
2018-02-07 14:01:37 -08:00
|
|
|
int width, int height, boolean quote)
|
2015-10-12 18:25:05 -07:00
|
|
|
{
|
2017-04-22 16:29:26 -07:00
|
|
|
this.contentType = contentType;
|
|
|
|
this.transferState = transferState;
|
|
|
|
this.size = size;
|
|
|
|
this.fileName = fileName;
|
|
|
|
this.location = location;
|
|
|
|
this.key = key;
|
|
|
|
this.relay = relay;
|
|
|
|
this.digest = digest;
|
|
|
|
this.fastPreflightId = fastPreflightId;
|
2017-05-11 22:46:35 -07:00
|
|
|
this.voiceNote = voiceNote;
|
2018-03-18 16:04:33 -07:00
|
|
|
this.width = width;
|
|
|
|
this.height = height;
|
2018-02-07 14:01:37 -08:00
|
|
|
this.quote = quote;
|
2015-10-12 18:25:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public abstract Uri getDataUri();
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public abstract Uri getThumbnailUri();
|
|
|
|
|
|
|
|
public int getTransferState() {
|
|
|
|
return transferState;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isInProgress() {
|
|
|
|
return transferState != AttachmentDatabase.TRANSFER_PROGRESS_DONE &&
|
|
|
|
transferState != AttachmentDatabase.TRANSFER_PROGRESS_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
public long getSize() {
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2017-03-28 12:05:30 -07:00
|
|
|
@Nullable
|
|
|
|
public String getFileName() {
|
|
|
|
return fileName;
|
|
|
|
}
|
|
|
|
|
2015-10-12 18:25:05 -07:00
|
|
|
@NonNull
|
|
|
|
public String getContentType() {
|
|
|
|
return contentType;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public String getLocation() {
|
|
|
|
return location;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public String getKey() {
|
|
|
|
return key;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public String getRelay() {
|
|
|
|
return relay;
|
|
|
|
}
|
2017-02-26 10:06:27 -08:00
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public byte[] getDigest() {
|
|
|
|
return digest;
|
|
|
|
}
|
2017-04-22 16:29:26 -07:00
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public String getFastPreflightId() {
|
|
|
|
return fastPreflightId;
|
|
|
|
}
|
2017-05-11 22:46:35 -07:00
|
|
|
|
|
|
|
public boolean isVoiceNote() {
|
|
|
|
return voiceNote;
|
|
|
|
}
|
2018-03-18 16:04:33 -07:00
|
|
|
|
|
|
|
public int getWidth() {
|
|
|
|
return width;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getHeight() {
|
|
|
|
return height;
|
|
|
|
}
|
2018-02-07 14:01:37 -08:00
|
|
|
|
|
|
|
public boolean isQuote() {
|
|
|
|
return quote;
|
|
|
|
}
|
2015-10-12 18:25:05 -07:00
|
|
|
}
|