Show 2 checks when sms is delivered

- differentiate between sent sms and delivered sms by updating the SmsStatusSentReceiver which updates the type to Telephony.Sms.MESSAGE_TYPE_SENT or Telephony.Sms.MESSAGE_TYPE_FAILED depending on the outcome.
- rename ThreadSuccess to ThreadSent and add a boolean field for the delivery status
- SmsStatusSentReceiver updates the status of the message to Telephony.Sms.STATUS_COMPLETE.
- accommodate for the need to keep track of the status by adding Int field status to the Message class,
- add appropriate database migrations (3 to 4) for the new status field.
- add status to the query for sms in extension function Context.getMessages and Context.getMMS
- add extension function Context.updateMessageStatus to update the status of a message in the database
This commit is contained in:
Paul Akhamiogu 2021-08-25 16:57:07 +01:00
parent 84c1705078
commit 46f71c994f
13 changed files with 58 additions and 27 deletions

View file

@ -99,7 +99,7 @@ class ThreadAdapter(
THREAD_DATE_TIME -> R.layout.item_thread_date_time
THREAD_RECEIVED_MESSAGE -> R.layout.item_received_message
THREAD_SENT_MESSAGE_ERROR -> R.layout.item_thread_error
THREAD_SENT_MESSAGE_SUCCESS -> R.layout.item_thread_success
THREAD_SENT_MESSAGE_SENT -> R.layout.item_thread_success
THREAD_SENT_MESSAGE_SENDING -> R.layout.item_thread_sending
else -> R.layout.item_sent_message
}
@ -113,7 +113,7 @@ class ThreadAdapter(
holder.bindView(item, isClickable, isLongClickable) { itemView, layoutPosition ->
when (item) {
is ThreadDateTime -> setupDateTime(itemView, item)
is ThreadSuccess -> setupThreadSuccess(itemView)
is ThreadSent -> setupThreadSuccess(itemView, item.delivered)
is ThreadError -> setupThreadError(itemView)
is ThreadSending -> setupThreadSending(itemView)
else -> setupView(itemView, item as Message)
@ -130,7 +130,7 @@ class ThreadAdapter(
item is ThreadDateTime -> THREAD_DATE_TIME
(messages[position] as? Message)?.isReceivedMessage() == true -> THREAD_RECEIVED_MESSAGE
item is ThreadError -> THREAD_SENT_MESSAGE_ERROR
item is ThreadSuccess -> THREAD_SENT_MESSAGE_SUCCESS
item is ThreadSent -> THREAD_SENT_MESSAGE_SENT
item is ThreadSending -> THREAD_SENT_MESSAGE_SENDING
else -> THREAD_SENT_MESSAGE
}
@ -350,7 +350,8 @@ class ThreadAdapter(
}
}
private fun setupThreadSuccess(view: View) {
private fun setupThreadSuccess(view: View, isDelivered: Boolean = false) {
view.thread_success.setImageResource(if (isDelivered) R.drawable.ic_check_double_vector else R.drawable.ic_check_vector)
view.thread_success.applyColorFilter(textColor)
}