Add message details menu button
Adds a "Properties" menu button in conversation, when one message is selected, which displays details about the message: - Type (SMS or MMS) - Sender phone number (or receiver if it is a sent message) - Used SIM - Date sent at - Date received at (if it is an incoming message) This closes #19
This commit is contained in:
parent
9942fb788a
commit
bdd506c96e
56 changed files with 530 additions and 29 deletions
|
|
@ -24,6 +24,7 @@ class SmsReceiver : BroadcastReceiver() {
|
|||
var body = ""
|
||||
var subject = ""
|
||||
var date = 0L
|
||||
var dateSent = 0L
|
||||
var threadId = 0L
|
||||
var status = Telephony.Sms.STATUS_NONE
|
||||
val type = Telephony.Sms.MESSAGE_TYPE_INBOX
|
||||
|
|
@ -38,6 +39,7 @@ class SmsReceiver : BroadcastReceiver() {
|
|||
status = it.status
|
||||
body += it.messageBody
|
||||
date = System.currentTimeMillis()
|
||||
dateSent = it.timestampMillis
|
||||
threadId = context.getThreadId(address)
|
||||
}
|
||||
|
||||
|
|
@ -45,17 +47,27 @@ class SmsReceiver : BroadcastReceiver() {
|
|||
val simpleContactsHelper = SimpleContactsHelper(context)
|
||||
simpleContactsHelper.exists(address, privateCursor) { exists ->
|
||||
if (exists) {
|
||||
handleMessage(context, address, subject, body, date, read, threadId, type, subscriptionId, status)
|
||||
handleMessage(context, address, subject, body, date, dateSent, read, threadId, type, subscriptionId, status)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
handleMessage(context, address, subject, body, date, read, threadId, type, subscriptionId, status)
|
||||
handleMessage(context, address, subject, body, date, dateSent, read, threadId, type, subscriptionId, status)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleMessage(
|
||||
context: Context, address: String, subject: String, body: String, date: Long, read: Int, threadId: Long, type: Int, subscriptionId: Int, status: Int
|
||||
context: Context,
|
||||
address: String,
|
||||
subject: String,
|
||||
body: String,
|
||||
date: Long,
|
||||
dateSent: Long,
|
||||
read: Int,
|
||||
threadId: Long,
|
||||
type: Int,
|
||||
subscriptionId: Int,
|
||||
status: Int
|
||||
) {
|
||||
val photoUri = SimpleContactsHelper(context).getPhotoUriFromPhoneNumber(address)
|
||||
val bitmap = context.getNotificationBitmap(photoUri)
|
||||
|
|
@ -63,7 +75,7 @@ class SmsReceiver : BroadcastReceiver() {
|
|||
if (!context.isNumberBlocked(address)) {
|
||||
val privateCursor = context.getMyContactsCursor(favoritesOnly = false, withPhoneNumbersOnly = true)
|
||||
ensureBackgroundThread {
|
||||
val newMessageId = context.insertNewSMS(address, subject, body, date, read, threadId, type, subscriptionId)
|
||||
val newMessageId = context.insertNewSMS(address, subject, body, date, dateSent, read, threadId, type, subscriptionId)
|
||||
|
||||
val conversation = context.getConversations(threadId).firstOrNull() ?: return@ensureBackgroundThread
|
||||
try {
|
||||
|
|
@ -81,6 +93,7 @@ class SmsReceiver : BroadcastReceiver() {
|
|||
val participant = SimpleContact(0, 0, senderName, photoUri, arrayListOf(phoneNumber), ArrayList(), ArrayList())
|
||||
val participants = arrayListOf(participant)
|
||||
val messageDate = (date / 1000).toInt()
|
||||
val messageSentDate = (dateSent / 1000).toInt()
|
||||
|
||||
val message =
|
||||
Message(
|
||||
|
|
@ -90,6 +103,7 @@ class SmsReceiver : BroadcastReceiver() {
|
|||
status,
|
||||
participants,
|
||||
messageDate,
|
||||
messageSentDate,
|
||||
false,
|
||||
threadId,
|
||||
false,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue