mirror of
https://github.com/SimpleMobileTools/Simple-SMS-Messenger.git
synced 2025-06-05 21:49:22 +02:00
Show error toast for attachments larger than MMS limit
This commit is contained in:
@@ -33,6 +33,7 @@ import android.view.inputmethod.EditorInfo
|
|||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import android.widget.LinearLayout.LayoutParams
|
import android.widget.LinearLayout.LayoutParams
|
||||||
import android.widget.RelativeLayout
|
import android.widget.RelativeLayout
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
import androidx.core.content.res.ResourcesCompat
|
import androidx.core.content.res.ResourcesCompat
|
||||||
@@ -1100,6 +1101,23 @@ class ThreadActivity : SimpleActivity() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val mimeType = contentResolver.getType(uri)
|
||||||
|
if (mimeType == null) {
|
||||||
|
toast(R.string.unknown_error_occurred)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val isImage = mimeType.isImageMimeType()
|
||||||
|
val isGif = mimeType.isGifMimeType()
|
||||||
|
if (isGif || !isImage) {
|
||||||
|
// is it assumed that images will always be compressed below the max MMS size limit
|
||||||
|
val fileSize = getFileSizeFromUri(uri)
|
||||||
|
val mmsFileSizeLimit = config.mmsFileSizeLimit
|
||||||
|
if (mmsFileSizeLimit != FILE_SIZE_NONE && fileSize > mmsFileSizeLimit) {
|
||||||
|
toast(R.string.attachment_sized_exceeds_max_limit, length = Toast.LENGTH_LONG)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var adapter = getAttachmentsAdapter()
|
var adapter = getAttachmentsAdapter()
|
||||||
if (adapter == null) {
|
if (adapter == null) {
|
||||||
adapter = AttachmentsAdapter(
|
adapter = AttachmentsAdapter(
|
||||||
@@ -1115,17 +1133,12 @@ class ThreadActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
thread_attachments_recyclerview.beVisible()
|
thread_attachments_recyclerview.beVisible()
|
||||||
val mimeType = contentResolver.getType(uri)
|
|
||||||
if (mimeType == null) {
|
|
||||||
toast(R.string.unknown_error_occurred)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
val attachment = AttachmentSelection(
|
val attachment = AttachmentSelection(
|
||||||
id = id,
|
id = id,
|
||||||
uri = uri,
|
uri = uri,
|
||||||
mimetype = mimeType,
|
mimetype = mimeType,
|
||||||
filename = getFilenameFromUri(uri),
|
filename = getFilenameFromUri(uri),
|
||||||
isPending = mimeType.isImageMimeType() && !mimeType.isGifMimeType()
|
isPending = isImage && !isGif
|
||||||
)
|
)
|
||||||
adapter.addAttachment(attachment)
|
adapter.addAttachment(attachment)
|
||||||
checkSendMessageAvailability()
|
checkSendMessageAvailability()
|
||||||
|
Reference in New Issue
Block a user