Skip to content

Commit 928246e

Browse files
committed
fix #206, solving a glitch with number being shown instead of name
1 parent 7a6f673 commit 928246e

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/ThreadActivity.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,6 @@ class ThreadActivity : SimpleActivity() {
431431
participants = if (messages.isEmpty()) {
432432
val intentNumbers = getPhoneNumbersFromIntent()
433433
val participants = getThreadParticipants(threadId, null)
434-
435434
fixParticipantNumbers(participants, intentNumbers)
436435
} else {
437436
messages.first().participants

app/src/main/kotlin/com/simplemobiletools/smsmessenger/receivers/SmsReceiver.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import android.content.Intent
66
import android.os.Handler
77
import android.os.Looper
88
import android.provider.Telephony
9+
import com.simplemobiletools.commons.extensions.getMyContactsCursor
910
import com.simplemobiletools.commons.extensions.isNumberBlocked
1011
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
1112
import 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

Comments
 (0)