fix #206, solving a glitch with number being shown instead of name
This commit is contained in:
parent
7a6f673e1e
commit
928246eaea
2 changed files with 5 additions and 2 deletions
|
|
@ -431,7 +431,6 @@ class ThreadActivity : SimpleActivity() {
|
||||||
participants = if (messages.isEmpty()) {
|
participants = if (messages.isEmpty()) {
|
||||||
val intentNumbers = getPhoneNumbersFromIntent()
|
val intentNumbers = getPhoneNumbersFromIntent()
|
||||||
val participants = getThreadParticipants(threadId, null)
|
val participants = getThreadParticipants(threadId, null)
|
||||||
|
|
||||||
fixParticipantNumbers(participants, intentNumbers)
|
fixParticipantNumbers(participants, intentNumbers)
|
||||||
} else {
|
} else {
|
||||||
messages.first().participants
|
messages.first().participants
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import android.content.Intent
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
import android.provider.Telephony
|
import android.provider.Telephony
|
||||||
|
import com.simplemobiletools.commons.extensions.getMyContactsCursor
|
||||||
import com.simplemobiletools.commons.extensions.isNumberBlocked
|
import com.simplemobiletools.commons.extensions.isNumberBlocked
|
||||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||||
import com.simplemobiletools.commons.models.SimpleContact
|
import com.simplemobiletools.commons.models.SimpleContact
|
||||||
|
|
@ -37,6 +38,7 @@ class SmsReceiver : BroadcastReceiver() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Handler(Looper.getMainLooper()).post {
|
Handler(Looper.getMainLooper()).post {
|
||||||
|
val privateCursor = context.getMyContactsCursor(false, true)?.loadInBackground()
|
||||||
if (!context.isNumberBlocked(address)) {
|
if (!context.isNumberBlocked(address)) {
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
val newMessageId = context.insertNewSMS(address, subject, body, date, read, threadId, type, subscriptionId)
|
val newMessageId = context.insertNewSMS(address, subject, body, date, read, threadId, type, subscriptionId)
|
||||||
|
|
@ -52,9 +54,11 @@ class SmsReceiver : BroadcastReceiver() {
|
||||||
} catch (ignored: Exception) {
|
} catch (ignored: Exception) {
|
||||||
}
|
}
|
||||||
|
|
||||||
val participant = SimpleContact(0, 0, address, "", arrayListOf(address), ArrayList(), ArrayList())
|
val senderName = context.getNameFromAddress(address, privateCursor)
|
||||||
|
val participant = SimpleContact(0, 0, senderName, "", arrayListOf(address), ArrayList(), ArrayList())
|
||||||
val participants = arrayListOf(participant)
|
val participants = arrayListOf(participant)
|
||||||
val messageDate = (date / 1000).toInt()
|
val messageDate = (date / 1000).toInt()
|
||||||
|
|
||||||
val message =
|
val message =
|
||||||
Message(newMessageId, body, type, status, participants, messageDate, false, threadId, false, null, address, "", subscriptionId)
|
Message(newMessageId, body, type, status, participants, messageDate, false, threadId, false, null, address, "", subscriptionId)
|
||||||
context.messagesDB.insertOrUpdate(message)
|
context.messagesDB.insertOrUpdate(message)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue