Merge pull request #289 from EveX1/feature/downsize-big-images

Downsize big images
This commit is contained in:
Tibor Kaputa 2022-02-05 23:03:49 +01:00 committed by GitHub
commit b2b8a38c7b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 120 additions and 18 deletions

View file

@ -677,6 +677,9 @@ class ThreadActivity : SimpleActivity() {
if (compressedUri != null) {
attachmentSelections[originalUriString] = AttachmentSelection(compressedUri, false)
loadAttachmentPreview(attachmentView, compressedUri)
} else {
toast(R.string.compress_error)
removeAttachment(attachmentView, originalUriString)
}
checkSendMessageAvailability()
attachmentView.thread_attachment_progress.beGone()
@ -690,11 +693,7 @@ class ThreadActivity : SimpleActivity() {
val attachmentView = layoutInflater.inflate(R.layout.item_attachment, null).apply {
thread_attachments_wrapper.addView(this)
thread_remove_attachment.setOnClickListener {
thread_attachments_wrapper.removeView(this)
attachmentSelections.remove(originalUri)
if (attachmentSelections.isEmpty()) {
thread_attachments_holder.beGone()
}
removeAttachment(this, originalUri)
}
}
@ -733,6 +732,14 @@ class ThreadActivity : SimpleActivity() {
.into(attachmentView.thread_attachment_preview)
}
private fun removeAttachment(attachmentView: View, originalUri: String) {
thread_attachments_wrapper.removeView(attachmentView)
attachmentSelections.remove(originalUri)
if (attachmentSelections.isEmpty()) {
thread_attachments_holder.beGone()
}
}
private fun checkSendMessageAvailability() {
if (thread_type_message.text.isNotEmpty() || (attachmentSelections.isNotEmpty() && !attachmentSelections.values.any { it.isPending })) {
thread_send_message.isClickable = true