Use original uri as `id` for attachment selections
This commit is contained in:
parent
c1c60e8971
commit
0eb5b79188
|
@ -893,7 +893,8 @@ class ThreadActivity : SimpleActivity() {
|
||||||
private fun getAttachmentSelections() = getAttachmentsAdapter()?.attachments ?: emptyList()
|
private fun getAttachmentSelections() = getAttachmentsAdapter()?.attachments ?: emptyList()
|
||||||
|
|
||||||
private fun addAttachment(uri: Uri) {
|
private fun addAttachment(uri: Uri) {
|
||||||
if (getAttachmentSelections().any { it.uri.toString() == uri.toString() }) {
|
val id = uri.toString()
|
||||||
|
if (getAttachmentSelections().any { it.id == id }) {
|
||||||
toast(R.string.duplicate_item_warning)
|
toast(R.string.duplicate_item_warning)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -915,6 +916,7 @@ class ThreadActivity : SimpleActivity() {
|
||||||
thread_attachments_recyclerview.beVisible()
|
thread_attachments_recyclerview.beVisible()
|
||||||
val mimeType = contentResolver.getType(uri).orEmpty()
|
val mimeType = contentResolver.getType(uri).orEmpty()
|
||||||
val attachment = AttachmentSelection(
|
val attachment = AttachmentSelection(
|
||||||
|
id = id,
|
||||||
uri = uri,
|
uri = uri,
|
||||||
mimetype = mimeType,
|
mimetype = mimeType,
|
||||||
filename = getFilenameFromUri(uri),
|
filename = getFilenameFromUri(uri),
|
||||||
|
|
|
@ -9,6 +9,7 @@ import com.simplemobiletools.smsmessenger.helpers.ATTACHMENT_MEDIA
|
||||||
import com.simplemobiletools.smsmessenger.helpers.ATTACHMENT_VCARD
|
import com.simplemobiletools.smsmessenger.helpers.ATTACHMENT_VCARD
|
||||||
|
|
||||||
data class AttachmentSelection(
|
data class AttachmentSelection(
|
||||||
|
val id: String,
|
||||||
val uri: Uri,
|
val uri: Uri,
|
||||||
val mimetype: String,
|
val mimetype: String,
|
||||||
val filename: String,
|
val filename: String,
|
||||||
|
@ -25,7 +26,7 @@ data class AttachmentSelection(
|
||||||
}
|
}
|
||||||
|
|
||||||
fun areItemsTheSame(first: AttachmentSelection, second: AttachmentSelection): Boolean {
|
fun areItemsTheSame(first: AttachmentSelection, second: AttachmentSelection): Boolean {
|
||||||
return first.uri == second.uri
|
return first.id == second.id
|
||||||
}
|
}
|
||||||
|
|
||||||
fun areContentsTheSame(first: AttachmentSelection, second: AttachmentSelection): Boolean {
|
fun areContentsTheSame(first: AttachmentSelection, second: AttachmentSelection): Boolean {
|
||||||
|
|
Loading…
Reference in New Issue