add error message on MMS compression failed

This commit is contained in:
EveX 2022-01-27 01:44:27 +01:00
parent 0774e0cb0f
commit 2605a61005
3 changed files with 13 additions and 1 deletions

View File

@ -671,6 +671,13 @@ class ThreadActivity : SimpleActivity() {
if (compressedUri != null) {
attachmentSelections[originalUriString] = AttachmentSelection(compressedUri, false)
loadAttachmentPreview(attachmentView, compressedUri)
} else {
toast(R.string.compress_error)
thread_attachments_wrapper.removeView(attachmentView)
attachmentSelections.remove(originalUriString)
if (attachmentSelections.isEmpty()) {
thread_attachments_holder.beGone()
}
}
checkSendMessageAvailability()
attachmentView.thread_attachment_progress.beGone()

View File

@ -106,7 +106,11 @@ class ImageCompressor(private val context: Context) {
private var iteration: Int = 0
fun isSatisfied(imageFile: File): Boolean {
return imageFile.length() <= maxFileSize || iteration >= maxIteration
// If size requirement is not met and iteration is maxed
if(iteration >= maxIteration && imageFile.length() >= maxFileSize) {
throw Exception("Unable to compress image to targeted size")
}
return imageFile.length() <= maxFileSize
}
fun satisfy(imageFile: File): File {

View File

@ -19,6 +19,7 @@
<string name="pin_conversation">Pin to the top</string>
<string name="unpin_conversation">Unpin</string>
<string name="forward_message">Forward</string>
<string name="compress_error">Unable to compress image to selected size</string>
<!-- New conversation -->
<string name="new_conversation">New conversation</string>
<string name="add_contact_or_number">Add Contact or Number…</string>