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 settings = Settings()
|
||||||
val message = Message(body, addresses.toTypedArray())
|
val message = Message(body, addresses.toTypedArray())
|
||||||
|
|
||||||
attachments
|
val bitmaps = attachments.map { uri -> RxImageConverters.uriToBitmap(context, uri).blockingFirst() }
|
||||||
.map { uri -> RxImageConverters.uriToBitmap(context, uri).blockingFirst() }
|
val totalBytes = bitmaps.sumBy { it.allocationByteCount }
|
||||||
.map { bitmap -> shrink(bitmap, prefs.mmsSize.get() * 1024) }
|
|
||||||
|
bitmaps
|
||||||
|
.map { bitmap ->
|
||||||
|
val byteRatio = bitmap.allocationByteCount / totalBytes.toFloat()
|
||||||
|
shrink(bitmap, (prefs.mmsSize.get() * 1024 * byteRatio).toInt())
|
||||||
|
}
|
||||||
.forEach { bitmap -> message.addMedia(bitmap, "image/jpeg") }
|
.forEach { bitmap -> message.addMedia(bitmap, "image/jpeg") }
|
||||||
|
|
||||||
val transaction = Transaction(context, settings)
|
val transaction = Transaction(context, settings)
|
||||||
|
|||||||
Reference in New Issue
Block a user