mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-05-01 14:13:22 +01:00
Support for generating video thumbnails
// FREEBIE
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package org.thoughtcrime.securesms.attachments;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
@@ -23,10 +22,6 @@ public abstract class Attachment {
|
||||
@Nullable
|
||||
private final String relay;
|
||||
|
||||
// XXX - This shouldn't be here.
|
||||
@Nullable
|
||||
private Bitmap thumbnail;
|
||||
|
||||
public Attachment(@NonNull String contentType, int transferState, long size,
|
||||
@Nullable String location, @Nullable String key, @Nullable String relay)
|
||||
{
|
||||
@@ -76,13 +71,4 @@ public abstract class Attachment {
|
||||
public String getRelay() {
|
||||
return relay;
|
||||
}
|
||||
|
||||
public void setThumbnail(@Nullable Bitmap thumbnail) {
|
||||
this.thumbnail = thumbnail;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Bitmap getThumbnail() {
|
||||
return thumbnail;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.thoughtcrime.securesms.attachments;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import org.thoughtcrime.securesms.mms.PartAuthority;
|
||||
|
||||
@@ -10,27 +10,38 @@ public class DatabaseAttachment extends Attachment {
|
||||
private final AttachmentId attachmentId;
|
||||
private final long mmsId;
|
||||
private final boolean hasData;
|
||||
private final boolean hasThumbnail;
|
||||
|
||||
public DatabaseAttachment(AttachmentId attachmentId, long mmsId, boolean hasData,
|
||||
public DatabaseAttachment(AttachmentId attachmentId, long mmsId,
|
||||
boolean hasData, boolean hasThumbnail,
|
||||
String contentType, int transferProgress, long size,
|
||||
String location, String key, String relay)
|
||||
{
|
||||
super(contentType, transferProgress, size, location, key, relay);
|
||||
this.attachmentId = attachmentId;
|
||||
this.hasData = hasData;
|
||||
this.hasThumbnail = hasThumbnail;
|
||||
this.mmsId = mmsId;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
@Nullable
|
||||
public Uri getDataUri() {
|
||||
return PartAuthority.getAttachmentDataUri(attachmentId);
|
||||
if (hasData) {
|
||||
return PartAuthority.getAttachmentDataUri(attachmentId);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
@Nullable
|
||||
public Uri getThumbnailUri() {
|
||||
return PartAuthority.getAttachmentThumbnailUri(attachmentId);
|
||||
if (hasThumbnail) {
|
||||
return PartAuthority.getAttachmentThumbnailUri(attachmentId);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public AttachmentId getAttachmentId() {
|
||||
@@ -56,4 +67,8 @@ public class DatabaseAttachment extends Attachment {
|
||||
public boolean hasData() {
|
||||
return hasData;
|
||||
}
|
||||
|
||||
public boolean hasThumbnail() {
|
||||
return hasThumbnail;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +1,19 @@
|
||||
package org.thoughtcrime.securesms.attachments;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
public class UriAttachment extends Attachment {
|
||||
|
||||
private final @NonNull Uri dataUri;
|
||||
private final @NonNull Uri thumbnailUri;
|
||||
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 dataUri, @NonNull Uri thumbnailUri,
|
||||
public UriAttachment(@NonNull Uri dataUri, @Nullable Uri thumbnailUri,
|
||||
@NonNull String contentType, int transferState, long size)
|
||||
{
|
||||
super(contentType, transferState, size, null, null, null);
|
||||
@@ -35,7 +28,7 @@ public class UriAttachment extends Attachment {
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
@Nullable
|
||||
public Uri getThumbnailUri() {
|
||||
return thumbnailUri;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user