diff --git a/app/src/main/java/org/thoughtcrime/securesms/giph/mp4/GiphyMp4PlaybackPolicy.java b/app/src/main/java/org/thoughtcrime/securesms/giph/mp4/GiphyMp4PlaybackPolicy.java index 159b5353c2..91852906fb 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/giph/mp4/GiphyMp4PlaybackPolicy.java +++ b/app/src/main/java/org/thoughtcrime/securesms/giph/mp4/GiphyMp4PlaybackPolicy.java @@ -23,6 +23,10 @@ public final class GiphyMp4PlaybackPolicy { private GiphyMp4PlaybackPolicy() { } + public static boolean sendAsMp4() { + return FeatureFlags.mp4GifSendSupport(); + } + public static boolean autoplay() { return !DeviceProperties.isLowMemoryDevice(ApplicationDependencies.getApplication()); } diff --git a/app/src/main/java/org/thoughtcrime/securesms/giph/mp4/GiphyMp4Repository.java b/app/src/main/java/org/thoughtcrime/securesms/giph/mp4/GiphyMp4Repository.java index 1de8db3d6c..f842b0610f 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/giph/mp4/GiphyMp4Repository.java +++ b/app/src/main/java/org/thoughtcrime/securesms/giph/mp4/GiphyMp4Repository.java @@ -51,15 +51,19 @@ final class GiphyMp4Repository { @WorkerThread private @NonNull Uri saveToBlobInternal(@NonNull GiphyImage giphyImage, boolean isForMms) throws IOException { + boolean sendAsMp4 = GiphyMp4PlaybackPolicy.sendAsMp4(); String url; String mime; - if (isForMms) { + if (sendAsMp4) { + url = giphyImage.getMp4Url(); + mime = MediaUtil.VIDEO_MP4; + } else if (isForMms) { url = giphyImage.getGifMmsUrl(); mime = MediaUtil.IMAGE_GIF; } else { - url = giphyImage.getMp4Url(); - mime = MediaUtil.VIDEO_MP4; + url = giphyImage.getGifUrl(); + mime = MediaUtil.IMAGE_GIF; } Request request = new Request.Builder().url(url).build(); diff --git a/app/src/main/java/org/thoughtcrime/securesms/mms/GifSlide.java b/app/src/main/java/org/thoughtcrime/securesms/mms/GifSlide.java index 9b3faede6a..aa6beb9021 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/mms/GifSlide.java +++ b/app/src/main/java/org/thoughtcrime/securesms/mms/GifSlide.java @@ -37,7 +37,7 @@ public class GifSlide extends ImageSlide { null, false, borderless, - true, + FeatureFlags.mp4GifSendSupport(), false)); this.borderless = borderless; diff --git a/app/src/main/java/org/thoughtcrime/securesms/util/FeatureFlags.java b/app/src/main/java/org/thoughtcrime/securesms/util/FeatureFlags.java index e57d6bf44d..760607596a 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/util/FeatureFlags.java +++ b/app/src/main/java/org/thoughtcrime/securesms/util/FeatureFlags.java @@ -74,6 +74,7 @@ public final class FeatureFlags { private static final String ANIMATED_STICKER_MIN_TOTAL_MEMORY = "android.animatedStickerMinTotalMemory"; private static final String MESSAGE_PROCESSOR_ALARM_INTERVAL = "android.messageProcessor.alarmIntervalMins"; private static final String MESSAGE_PROCESSOR_DELAY = "android.messageProcessor.foregroundDelayMs"; + private static final String MP4_GIF_SEND_SUPPORT = "android.mp4GifSendSupport.2"; private static final String MEDIA_QUALITY_LEVELS = "android.mediaQuality.levels"; private static final String RETRY_RECEIPT_LIFESPAN = "android.retryReceiptLifespan"; private static final String RETRY_RESPOND_MAX_AGE = "android.retryRespondMaxAge"; @@ -111,6 +112,7 @@ public final class FeatureFlags { ANIMATED_STICKER_MIN_TOTAL_MEMORY, MESSAGE_PROCESSOR_ALARM_INTERVAL, MESSAGE_PROCESSOR_DELAY, + MP4_GIF_SEND_SUPPORT, MEDIA_QUALITY_LEVELS, RETRY_RECEIPT_LIFESPAN, RETRY_RESPOND_MAX_AGE, @@ -162,6 +164,7 @@ public final class FeatureFlags { ANIMATED_STICKER_MIN_TOTAL_MEMORY, MESSAGE_PROCESSOR_ALARM_INTERVAL, MESSAGE_PROCESSOR_DELAY, + MP4_GIF_SEND_SUPPORT, MEDIA_QUALITY_LEVELS, RETRY_RECEIPT_LIFESPAN, RETRY_RESPOND_MAX_AGE, @@ -348,6 +351,10 @@ public final class FeatureFlags { return getInteger(ANIMATED_STICKER_MIN_TOTAL_MEMORY, (int) ByteUnit.GIGABYTES.toMegabytes(3)); } + public static boolean mp4GifSendSupport() { + return getBoolean(MP4_GIF_SEND_SUPPORT, false); + } + public static @NonNull String getMediaQualityLevels() { return getString(MEDIA_QUALITY_LEVELS, ""); }