mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 17:29:32 +01:00
Add support for borderless images.
Added support for 'borderless' images. Basically images that we'd like to render as if they were stickers, even though they're not stickers. On iOS, this will be stuff like memoji and bitmoji. On Android, in my initial pass, I've just added support for Giphy stickers. However, we can also detect bitmoji and keyboard stickers in the future. This is kind of a 'best effort' thing, so as long as we support receiving, we can just add sending support for more things as we go.
This commit is contained in:
@@ -35,11 +35,11 @@ import org.thoughtcrime.securesms.util.ResUtil;
|
||||
public class AudioSlide extends Slide {
|
||||
|
||||
public AudioSlide(Context context, Uri uri, long dataSize, boolean voiceNote) {
|
||||
super(context, constructAttachmentFromUri(context, uri, MediaUtil.AUDIO_UNSPECIFIED, dataSize, 0, 0, false, null, null, null, null, null, voiceNote, false));
|
||||
super(context, constructAttachmentFromUri(context, uri, MediaUtil.AUDIO_UNSPECIFIED, dataSize, 0, 0, false, null, null, null, null, null, voiceNote, false, false));
|
||||
}
|
||||
|
||||
public AudioSlide(Context context, Uri uri, long dataSize, String contentType, boolean voiceNote) {
|
||||
super(context, new UriAttachment(uri, null, contentType, AttachmentDatabase.TRANSFER_PROGRESS_STARTED, dataSize, 0, 0, null, null, voiceNote, false, null, null, null, null, null));
|
||||
super(context, new UriAttachment(uri, null, contentType, AttachmentDatabase.TRANSFER_PROGRESS_STARTED, dataSize, 0, 0, null, null, voiceNote, false, false, null, null, null, null, null));
|
||||
}
|
||||
|
||||
public AudioSlide(Context context, Attachment attachment) {
|
||||
|
||||
@@ -20,7 +20,7 @@ public class DocumentSlide extends Slide {
|
||||
@NonNull String contentType, long size,
|
||||
@Nullable String fileName)
|
||||
{
|
||||
super(context, constructAttachmentFromUri(context, uri, contentType, size, 0, 0, true, StorageUtil.getCleanFileName(fileName), null, null, null, null, false, false));
|
||||
super(context, constructAttachmentFromUri(context, uri, contentType, size, 0, 0, true, StorageUtil.getCleanFileName(fileName), null, null, null, null, false, false, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,22 +10,29 @@ import org.thoughtcrime.securesms.util.MediaUtil;
|
||||
|
||||
public class GifSlide extends ImageSlide {
|
||||
|
||||
private final boolean borderless;
|
||||
|
||||
public GifSlide(Context context, Attachment attachment) {
|
||||
super(context, attachment);
|
||||
this.borderless = attachment.isBorderless();
|
||||
}
|
||||
|
||||
|
||||
public GifSlide(Context context, Uri uri, long size, int width, int height) {
|
||||
this(context, uri, size, width, height, null);
|
||||
this(context, uri, size, width, height, false, null);
|
||||
}
|
||||
|
||||
public GifSlide(Context context, Uri uri, long size, int width, int height, @Nullable String caption) {
|
||||
super(context, constructAttachmentFromUri(context, uri, MediaUtil.IMAGE_GIF, size, width, height, true, null, caption, null, null, null, false, false));
|
||||
public GifSlide(Context context, Uri uri, long size, int width, int height, boolean borderless, @Nullable String caption) {
|
||||
super(context, constructAttachmentFromUri(context, uri, MediaUtil.IMAGE_GIF, size, width, height, true, null, caption, null, null, null, false, borderless, false));
|
||||
this.borderless = borderless;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Uri getThumbnailUri() {
|
||||
public @Nullable Uri getThumbnailUri() {
|
||||
return getUri();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBorderless() {
|
||||
return borderless;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,19 +30,24 @@ import org.thoughtcrime.securesms.util.MediaUtil;
|
||||
|
||||
public class ImageSlide extends Slide {
|
||||
|
||||
private final boolean borderless;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static final String TAG = ImageSlide.class.getSimpleName();
|
||||
|
||||
public ImageSlide(@NonNull Context context, @NonNull Attachment attachment) {
|
||||
super(context, attachment);
|
||||
this.borderless = attachment.isBorderless();
|
||||
}
|
||||
|
||||
public ImageSlide(Context context, Uri uri, long size, int width, int height, @Nullable BlurHash blurHash) {
|
||||
this(context, uri, size, width, height, null, blurHash);
|
||||
this(context, uri, size, width, height, false, null, blurHash);
|
||||
}
|
||||
|
||||
public ImageSlide(Context context, Uri uri, long size, int width, int height, @Nullable String caption, @Nullable BlurHash blurHash) {
|
||||
super(context, constructAttachmentFromUri(context, uri, MediaUtil.IMAGE_JPEG, size, width, height, true, null, caption, null, blurHash, null, false, false));
|
||||
public ImageSlide(Context context, Uri uri, long size, int width, int height, boolean borderless, @Nullable String caption, @Nullable BlurHash blurHash) {
|
||||
// TODO [greyson] [borderless] Handle borderless
|
||||
super(context, constructAttachmentFromUri(context, uri, MediaUtil.IMAGE_JPEG, size, width, height, true, null, caption, null, blurHash, null, false, borderless, false));
|
||||
this.borderless = borderless;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -65,6 +70,11 @@ public class ImageSlide extends Slide {
|
||||
return getPlaceholderBlur() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBorderless() {
|
||||
return borderless;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getContentDescription() {
|
||||
|
||||
@@ -110,6 +110,10 @@ public abstract class Slide {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isBorderless() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public @NonNull String getContentDescription() { return ""; }
|
||||
|
||||
public @NonNull Attachment asAttachment() {
|
||||
@@ -158,9 +162,10 @@ public abstract class Slide {
|
||||
@Nullable BlurHash blurHash,
|
||||
@Nullable AudioHash audioHash,
|
||||
boolean voiceNote,
|
||||
boolean borderless,
|
||||
boolean quote)
|
||||
{
|
||||
return constructAttachmentFromUri(context, uri, defaultMime, size, width, height, hasThumbnail, fileName, caption, stickerLocator, blurHash, audioHash, voiceNote, quote, null);
|
||||
return constructAttachmentFromUri(context, uri, defaultMime, size, width, height, hasThumbnail, fileName, caption, stickerLocator, blurHash, audioHash, voiceNote, borderless, quote, null);
|
||||
}
|
||||
|
||||
protected static Attachment constructAttachmentFromUri(@NonNull Context context,
|
||||
@@ -176,6 +181,7 @@ public abstract class Slide {
|
||||
@Nullable BlurHash blurHash,
|
||||
@Nullable AudioHash audioHash,
|
||||
boolean voiceNote,
|
||||
boolean borderless,
|
||||
boolean quote,
|
||||
@Nullable AttachmentDatabase.TransformProperties transformProperties)
|
||||
{
|
||||
@@ -191,6 +197,7 @@ public abstract class Slide {
|
||||
fileName,
|
||||
fastPreflightId,
|
||||
voiceNote,
|
||||
borderless,
|
||||
quote,
|
||||
caption,
|
||||
stickerLocator,
|
||||
|
||||
@@ -23,7 +23,7 @@ public class StickerSlide extends Slide {
|
||||
}
|
||||
|
||||
public StickerSlide(Context context, Uri uri, long size, @NonNull StickerLocator stickerLocator) {
|
||||
super(context, constructAttachmentFromUri(context, uri, MediaUtil.IMAGE_WEBP, size, WIDTH, HEIGHT, true, null, null, stickerLocator, null, null, false, false));
|
||||
super(context, constructAttachmentFromUri(context, uri, MediaUtil.IMAGE_WEBP, size, WIDTH, HEIGHT, true, null, null, stickerLocator, null, null, false, false, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,6 +17,6 @@ public class TextSlide extends Slide {
|
||||
}
|
||||
|
||||
public TextSlide(@NonNull Context context, @NonNull Uri uri, @Nullable String filename, long size) {
|
||||
super(context, constructAttachmentFromUri(context, uri, MediaUtil.LONG_TEXT, size, 0, 0, true, filename, null, null, null, null, false, false));
|
||||
super(context, constructAttachmentFromUri(context, uri, MediaUtil.LONG_TEXT, size, 0, 0, true, filename, null, null, null, null, false, false, false));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class VideoSlide extends Slide {
|
||||
}
|
||||
|
||||
public VideoSlide(Context context, Uri uri, long dataSize, @Nullable String caption, @Nullable AttachmentDatabase.TransformProperties transformProperties) {
|
||||
super(context, constructAttachmentFromUri(context, uri, MediaUtil.VIDEO_UNSPECIFIED, dataSize, 0, 0, MediaUtil.hasVideoThumbnail(uri), null, caption, null, null, null, false, false, transformProperties));
|
||||
super(context, constructAttachmentFromUri(context, uri, MediaUtil.VIDEO_UNSPECIFIED, dataSize, 0, 0, MediaUtil.hasVideoThumbnail(uri), null, caption, null, null, null, false, false, false, transformProperties));
|
||||
}
|
||||
|
||||
public VideoSlide(Context context, Attachment attachment) {
|
||||
|
||||
Reference in New Issue
Block a user