mirror of
https://github.com/SimpleMobileTools/Simple-SMS-Messenger.git
synced 2025-06-05 21:49:22 +02:00
properly handle deleting MMS messages
This commit is contained in:
@@ -152,7 +152,7 @@ class ThreadAdapter(
|
|||||||
val messagesToRemove = messages.filter { selectedKeys.contains((it as? Message)?.id ?: 0) } as ArrayList<ThreadItem>
|
val messagesToRemove = messages.filter { selectedKeys.contains((it as? Message)?.id ?: 0) } as ArrayList<ThreadItem>
|
||||||
val positions = getSelectedItemPositions()
|
val positions = getSelectedItemPositions()
|
||||||
messagesToRemove.forEach {
|
messagesToRemove.forEach {
|
||||||
activity.deleteMessage((it as Message).id)
|
activity.deleteMessage((it as Message).id, it.isMMS)
|
||||||
}
|
}
|
||||||
messages.removeAll(messagesToRemove)
|
messages.removeAll(messagesToRemove)
|
||||||
|
|
||||||
|
@@ -205,6 +205,7 @@ fun Context.getConversations(): ArrayList<Conversation> {
|
|||||||
val conversation = Conversation(id, snippet, date.toInt(), read, title, photoUri, isGroupConversation)
|
val conversation = Conversation(id, snippet, date.toInt(), read, title, photoUri, isGroupConversation)
|
||||||
conversations.add(conversation)
|
conversations.add(conversation)
|
||||||
}
|
}
|
||||||
|
|
||||||
return conversations
|
return conversations
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -576,14 +577,17 @@ fun Context.insertNewSMS(address: String, subject: String, body: String, date: L
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun Context.deleteConversation(id: Int) {
|
fun Context.deleteConversation(id: Int) {
|
||||||
val uri = Sms.CONTENT_URI
|
var uri = Sms.CONTENT_URI
|
||||||
val selection = "${Sms.THREAD_ID} = ?"
|
val selection = "${Sms.THREAD_ID} = ?"
|
||||||
val selectionArgs = arrayOf(id.toString())
|
val selectionArgs = arrayOf(id.toString())
|
||||||
contentResolver.delete(uri, selection, selectionArgs)
|
contentResolver.delete(uri, selection, selectionArgs)
|
||||||
|
|
||||||
|
uri = Mms.CONTENT_URI
|
||||||
|
contentResolver.delete(uri, selection, selectionArgs)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Context.deleteMessage(id: Int) {
|
fun Context.deleteMessage(id: Int, isMMS: Boolean) {
|
||||||
val uri = Sms.CONTENT_URI
|
val uri = if (isMMS) Mms.CONTENT_URI else Sms.CONTENT_URI
|
||||||
val selection = "${Sms._ID} = ?"
|
val selection = "${Sms._ID} = ?"
|
||||||
val selectionArgs = arrayOf(id.toString())
|
val selectionArgs = arrayOf(id.toString())
|
||||||
contentResolver.delete(uri, selection, selectionArgs)
|
contentResolver.delete(uri, selection, selectionArgs)
|
||||||
|
Reference in New Issue
Block a user