From 863ac7f2e5a9d94048c622d881a99edd27466e10 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 28 Sep 2019 23:56:02 +0200 Subject: [PATCH] show resource prompt when sending uncompressed video --- .../eu/siacs/conversations/persistance/FileBackend.java | 4 +++- .../services/AttachFileToConversationRunnable.java | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java index 509d4b193..fe6530b66 100644 --- a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java +++ b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java @@ -56,6 +56,7 @@ import eu.siacs.conversations.Config; import eu.siacs.conversations.R; import eu.siacs.conversations.entities.DownloadableFile; import eu.siacs.conversations.entities.Message; +import eu.siacs.conversations.services.AttachFileToConversationRunnable; import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.ui.RecordingActivity; import eu.siacs.conversations.ui.util.Attachment; @@ -111,6 +112,7 @@ public class FileBackend { } public static boolean allFilesUnderSize(Context context, List attachments, long max) { + final boolean compressVideo = !AttachFileToConversationRunnable.getVideoCompression(context).equals("uncompressed"); if (max <= 0) { Log.d(Config.LOGTAG, "server did not report max file size for http upload"); return true; //exception to be compatible with HTTP Upload < v0.2 @@ -120,7 +122,7 @@ public class FileBackend { continue; } String mime = attachment.getMime(); - if (mime != null && mime.startsWith("video/")) { + if (mime != null && mime.startsWith("video/") && compressVideo) { try { Dimensions dimensions = FileBackend.getVideoDimensions(context, attachment.getUri()); if (dimensions.getMin() > 720) { diff --git a/src/main/java/eu/siacs/conversations/services/AttachFileToConversationRunnable.java b/src/main/java/eu/siacs/conversations/services/AttachFileToConversationRunnable.java index 21ab5fb00..eb3380396 100644 --- a/src/main/java/eu/siacs/conversations/services/AttachFileToConversationRunnable.java +++ b/src/main/java/eu/siacs/conversations/services/AttachFileToConversationRunnable.java @@ -1,5 +1,6 @@ package eu.siacs.conversations.services; +import android.content.Context; import android.content.SharedPreferences; import android.net.Uri; import android.os.Build; @@ -177,7 +178,11 @@ public class AttachFileToConversationRunnable implements Runnable, MediaTranscod } private String getVideoCompression() { - final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(mXmppConnectionService); - return preferences.getString("video_compression", mXmppConnectionService.getResources().getString(R.string.video_compression)); + return getVideoCompression(mXmppConnectionService); + } + + public static String getVideoCompression(final Context context) { + final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); + return preferences.getString("video_compression", context.getResources().getString(R.string.video_compression)); } }