forked from upstream-mirrors/quik
Apply max mms size to entire message instead of every attachment
This commit is contained in:
@@ -55,9 +55,14 @@ class SendMessage @Inject constructor(
|
||||
val settings = Settings()
|
||||
val message = Message(body, addresses.toTypedArray())
|
||||
|
||||
attachments
|
||||
.map { uri -> RxImageConverters.uriToBitmap(context, uri).blockingFirst() }
|
||||
.map { bitmap -> shrink(bitmap, prefs.mmsSize.get() * 1024) }
|
||||
val bitmaps = attachments.map { uri -> RxImageConverters.uriToBitmap(context, uri).blockingFirst() }
|
||||
val totalBytes = bitmaps.sumBy { it.allocationByteCount }
|
||||
|
||||
bitmaps
|
||||
.map { bitmap ->
|
||||
val byteRatio = bitmap.allocationByteCount / totalBytes.toFloat()
|
||||
shrink(bitmap, (prefs.mmsSize.get() * 1024 * byteRatio).toInt())
|
||||
}
|
||||
.forEach { bitmap -> message.addMedia(bitmap, "image/jpeg") }
|
||||
|
||||
val transaction = Transaction(context, settings)
|
||||
|
||||
Reference in New Issue
Block a user