diff options
author | Christian Schneppe <christian.schneppe@pix-art.de> | 2019-09-29 14:18:14 +0200 |
---|---|---|
committer | Christian Schneppe <christian.schneppe@pix-art.de> | 2019-09-29 14:18:14 +0200 |
commit | d852745b2ca59610a0b8f2271545befd697ec7a8 (patch) | |
tree | 130d83cd5966d82ff7b6307de62745bfc1c355cd /src/main/java/de | |
parent | c5c8ba4f31cf949d242280e09ec4e50f0be59a13 (diff) |
show resource prompt when sending uncompressed video
Diffstat (limited to 'src/main/java/de')
-rw-r--r-- | src/main/java/de/pixart/messenger/persistance/FileBackend.java | 4 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/services/AttachFileToConversationRunnable.java | 15 |
2 files changed, 17 insertions, 2 deletions
diff --git a/src/main/java/de/pixart/messenger/persistance/FileBackend.java b/src/main/java/de/pixart/messenger/persistance/FileBackend.java index 274b84c08..e34cb9074 100644 --- a/src/main/java/de/pixart/messenger/persistance/FileBackend.java +++ b/src/main/java/de/pixart/messenger/persistance/FileBackend.java @@ -60,6 +60,7 @@ import de.pixart.messenger.Config; import de.pixart.messenger.R; import de.pixart.messenger.entities.DownloadableFile; import de.pixart.messenger.entities.Message; +import de.pixart.messenger.services.AttachFileToConversationRunnable; import de.pixart.messenger.services.XmppConnectionService; import de.pixart.messenger.ui.util.Attachment; import de.pixart.messenger.utils.CryptoHelper; @@ -271,6 +272,7 @@ public class FileBackend { } public static boolean allFilesUnderSize(Context context, List<Attachment> 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 @@ -280,7 +282,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/de/pixart/messenger/services/AttachFileToConversationRunnable.java b/src/main/java/de/pixart/messenger/services/AttachFileToConversationRunnable.java index a56d3cea2..bb907a5cd 100644 --- a/src/main/java/de/pixart/messenger/services/AttachFileToConversationRunnable.java +++ b/src/main/java/de/pixart/messenger/services/AttachFileToConversationRunnable.java @@ -1,11 +1,15 @@ package de.pixart.messenger.services; +import android.content.Context; +import android.content.SharedPreferences; import android.net.Uri; import android.os.Build; import android.os.ParcelFileDescriptor; -import androidx.annotation.RequiresApi; +import android.preference.PreferenceManager; import android.util.Log; +import androidx.annotation.RequiresApi; + import net.ypresto.androidtranscoder.MediaTranscoder; import net.ypresto.androidtranscoder.format.MediaFormatStrategyPresets; @@ -178,6 +182,15 @@ public class AttachFileToConversationRunnable implements Runnable, MediaTranscod } } + private String getVideoCompression() { + 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)); + } + public FileBackend getFileBackend() { return mXmppConnectionService.fileBackend; } |