@@ -6,6 +6,7 @@ import android.content.Intent
66import android.os.Handler
77import android.os.Looper
88import android.provider.Telephony
9+ import com.simplemobiletools.commons.extensions.getMyContactsCursor
910import com.simplemobiletools.commons.extensions.isNumberBlocked
1011import com.simplemobiletools.commons.helpers.ensureBackgroundThread
1112import com.simplemobiletools.commons.models.SimpleContact
@@ -37,6 +38,7 @@ class SmsReceiver : BroadcastReceiver() {
3738 }
3839
3940 Handler (Looper .getMainLooper()).post {
41+ val privateCursor = context.getMyContactsCursor(false , true )?.loadInBackground()
4042 if (! context.isNumberBlocked(address)) {
4143 ensureBackgroundThread {
4244 val newMessageId = context.insertNewSMS(address, subject, body, date, read, threadId, type, subscriptionId)
@@ -52,9 +54,11 @@ class SmsReceiver : BroadcastReceiver() {
5254 } catch (ignored: Exception ) {
5355 }
5456
55- val participant = SimpleContact (0 , 0 , address, " " , arrayListOf (address), ArrayList (), ArrayList ())
57+ val senderName = context.getNameFromAddress(address, privateCursor)
58+ val participant = SimpleContact (0 , 0 , senderName, " " , arrayListOf (address), ArrayList (), ArrayList ())
5659 val participants = arrayListOf (participant)
5760 val messageDate = (date / 1000 ).toInt()
61+
5862 val message =
5963 Message (newMessageId, body, type, status, participants, messageDate, false , threadId, false , null , address, " " , subscriptionId)
6064 context.messagesDB.insertOrUpdate(message)
0 commit comments