mirror of
https://github.com/SimpleMobileTools/Simple-SMS-Messenger.git
synced 2025-01-05 21:07:35 +01:00
fetch the message Thread field too and group by it
This commit is contained in:
parent
c1363e4d22
commit
960b16c99b
@ -77,12 +77,14 @@ class MainActivity : SimpleActivity() {
|
||||
Telephony.Sms.ADDRESS,
|
||||
Telephony.Sms.PERSON,
|
||||
Telephony.Sms.DATE,
|
||||
Telephony.Sms.READ
|
||||
Telephony.Sms.READ,
|
||||
Telephony.Sms.THREAD_ID
|
||||
)
|
||||
val selection = "1 == 1) GROUP BY (${Telephony.Sms.THREAD_ID}"
|
||||
|
||||
var cursor: Cursor? = null
|
||||
try {
|
||||
cursor = contentResolver.query(uri, projection, null, null, null)
|
||||
cursor = contentResolver.query(uri, projection, selection, null, null)
|
||||
if (cursor?.moveToFirst() == true) {
|
||||
do {
|
||||
val id = cursor.getIntValue(Telephony.Sms._ID)
|
||||
@ -93,11 +95,12 @@ class MainActivity : SimpleActivity() {
|
||||
val date = (cursor.getLongValue(Telephony.Sms.DATE) / 1000).toInt()
|
||||
val read = cursor.getIntValue(Telephony.Sms.READ) == 1
|
||||
val person = cursor.getIntValue(Telephony.Sms.PERSON)
|
||||
val thread = cursor.getIntValue(Telephony.Sms.THREAD_ID)
|
||||
if (address != null && person != 0 && hasContactsPermission) {
|
||||
address = getPersonsName(person) ?: address
|
||||
}
|
||||
|
||||
val message = Message(id, subject, body, type, address, date, read)
|
||||
val message = Message(id, subject, body, type, address, date, read, thread)
|
||||
messages.add(message)
|
||||
} while (cursor.moveToNext())
|
||||
}
|
||||
|
@ -1,3 +1,6 @@
|
||||
package com.simplemobiletools.smsmessenger.models
|
||||
|
||||
data class Message(val id: Int, val subject: String, val body: String, val type: Int, val address: String, val date: Int, val read: Boolean)
|
||||
data class Message(
|
||||
val id: Int, val subject: String, val body: String, val type: Int, val address: String, val date: Int, val read: Boolean,
|
||||
val thread: Int
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user