mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 18:00:02 +01:00
Extract Media and TransformProperties to core/util/models.
This commit is contained in:
@@ -28,7 +28,7 @@ import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
||||
import org.thoughtcrime.securesms.blurhash.BlurHash;
|
||||
import org.thoughtcrime.securesms.database.AttachmentTable.TransformProperties;
|
||||
import org.signal.core.models.media.TransformProperties;
|
||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||
|
||||
public class ImageSlide extends Slide {
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.thoughtcrime.securesms.BuildConfig;
|
||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
||||
import org.thoughtcrime.securesms.attachments.AttachmentId;
|
||||
import org.thoughtcrime.securesms.avatar.AvatarPickerStorage;
|
||||
import org.signal.core.models.media.TransformProperties;
|
||||
import org.thoughtcrime.securesms.database.AttachmentTable;
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase;
|
||||
import org.thoughtcrime.securesms.emoji.EmojiFiles;
|
||||
@@ -160,7 +161,7 @@ public class PartAuthority {
|
||||
}
|
||||
}
|
||||
|
||||
public static @Nullable AttachmentTable.TransformProperties getAttachmentTransformProperties(@NonNull Uri uri) {
|
||||
public static @Nullable TransformProperties getAttachmentTransformProperties(@NonNull Uri uri) {
|
||||
int match = uriMatcher.match(uri);
|
||||
switch (match) {
|
||||
case PART_ROW:
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.thoughtcrime.securesms.attachments.Attachment;
|
||||
import org.thoughtcrime.securesms.attachments.UriAttachment;
|
||||
import org.thoughtcrime.securesms.audio.AudioHash;
|
||||
import org.thoughtcrime.securesms.blurhash.BlurHash;
|
||||
import org.signal.core.models.media.TransformProperties;
|
||||
import org.thoughtcrime.securesms.database.AttachmentTable;
|
||||
import org.thoughtcrime.securesms.stickers.StickerLocator;
|
||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||
@@ -211,7 +212,7 @@ public abstract class Slide {
|
||||
boolean borderless,
|
||||
boolean gif,
|
||||
boolean quote,
|
||||
@Nullable AttachmentTable.TransformProperties transformProperties)
|
||||
@Nullable TransformProperties transformProperties)
|
||||
{
|
||||
String resolvedType = Optional.ofNullable(MediaUtil.getMimeType(context, uri)).orElse(defaultMime);
|
||||
String fastPreflightId = String.valueOf(new SecureRandom().nextLong());
|
||||
|
||||
@@ -12,6 +12,7 @@ import androidx.annotation.Nullable;
|
||||
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.blurhash.BlurHash;
|
||||
import org.signal.core.models.media.TransformProperties;
|
||||
import org.thoughtcrime.securesms.database.AttachmentTable;
|
||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||
|
||||
@@ -41,7 +42,7 @@ public final class SlideFactory {
|
||||
*
|
||||
* @return A Slide with all the information we can gather about it.
|
||||
*/
|
||||
public static @Nullable Slide getSlide(@NonNull Context context, @Nullable String contentType, @NonNull Uri uri, int width, int height, @Nullable AttachmentTable.TransformProperties transformProperties) {
|
||||
public static @Nullable Slide getSlide(@NonNull Context context, @Nullable String contentType, @NonNull Uri uri, int width, int height, @Nullable TransformProperties transformProperties) {
|
||||
MediaType mediaType = MediaType.from(contentType);
|
||||
|
||||
try {
|
||||
@@ -65,7 +66,7 @@ public final class SlideFactory {
|
||||
@NonNull Uri uri,
|
||||
int width,
|
||||
int height,
|
||||
@Nullable AttachmentTable.TransformProperties transformProperties
|
||||
@Nullable TransformProperties transformProperties
|
||||
) {
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
@@ -99,7 +100,7 @@ public final class SlideFactory {
|
||||
@NonNull Uri uri,
|
||||
int width,
|
||||
int height,
|
||||
@Nullable AttachmentTable.TransformProperties transformProperties
|
||||
@Nullable TransformProperties transformProperties
|
||||
) throws IOException
|
||||
{
|
||||
long start = System.currentTimeMillis();
|
||||
@@ -162,7 +163,7 @@ public final class SlideFactory {
|
||||
int width,
|
||||
int height,
|
||||
boolean gif,
|
||||
@Nullable AttachmentTable.TransformProperties transformProperties)
|
||||
@Nullable TransformProperties transformProperties)
|
||||
{
|
||||
if (mimeType == null) {
|
||||
mimeType = "application/octet-stream";
|
||||
@@ -172,7 +173,7 @@ public final class SlideFactory {
|
||||
case IMAGE: return new ImageSlide(context, uri, mimeType, dataSize, width, height, false, null, blurHash, transformProperties);
|
||||
case GIF: return new GifSlide(context, uri, dataSize, width, height);
|
||||
case AUDIO: return new AudioSlide(context, uri, dataSize, false);
|
||||
case VIDEO: return new VideoSlide(context, uri, dataSize, gif, null, AttachmentTable.TransformProperties.forSentMediaQuality(transformProperties != null ? transformProperties.sentMediaQuality : SentMediaQuality.STANDARD.getCode()));
|
||||
case VIDEO: return new VideoSlide(context, uri, dataSize, gif, null, TransformProperties.forSentMediaQuality(transformProperties != null ? transformProperties.sentMediaQuality : SentMediaQuality.STANDARD.getCode()));
|
||||
case VCARD:
|
||||
case DOCUMENT: return new DocumentSlide(context, uri, mimeType, dataSize, fileName);
|
||||
default: throw new AssertionError("unrecognized enum");
|
||||
|
||||
@@ -26,6 +26,7 @@ import androidx.annotation.Nullable;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
||||
import org.signal.core.models.media.TransformProperties;
|
||||
import org.thoughtcrime.securesms.database.AttachmentTable;
|
||||
import org.thoughtcrime.securesms.giph.mp4.GiphyMp4PlaybackPolicy;
|
||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||
@@ -36,11 +37,11 @@ public class VideoSlide extends Slide {
|
||||
this(context, uri, dataSize, gif, null, null);
|
||||
}
|
||||
|
||||
public VideoSlide(Context context, Uri uri, long dataSize, boolean gif, @Nullable String caption, @Nullable AttachmentTable.TransformProperties transformProperties) {
|
||||
public VideoSlide(Context context, Uri uri, long dataSize, boolean gif, @Nullable String caption, @Nullable TransformProperties transformProperties) {
|
||||
super(constructAttachmentFromUri(context, uri, MediaUtil.VIDEO_UNSPECIFIED, dataSize, 0, 0, MediaUtil.hasVideoThumbnail(context, uri), null, caption, null, null, null, false, false, gif, false, transformProperties));
|
||||
}
|
||||
|
||||
public VideoSlide(Context context, Uri uri, long dataSize, boolean gif, int width, int height, @Nullable String caption, @Nullable AttachmentTable.TransformProperties transformProperties) {
|
||||
public VideoSlide(Context context, Uri uri, long dataSize, boolean gif, int width, int height, @Nullable String caption, @Nullable TransformProperties transformProperties) {
|
||||
super(constructAttachmentFromUri(context, uri, MediaUtil.VIDEO_UNSPECIFIED, dataSize, width, height, MediaUtil.hasVideoThumbnail(context, uri), null, caption, null, null, null, false, false, gif, false, transformProperties));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user