Handle sending scheduled messages
This commit is contained in:
parent
16ea540d48
commit
2ff0880cb5
14 changed files with 306 additions and 75 deletions
|
|
@ -4,10 +4,10 @@ import android.annotation.SuppressLint
|
|||
import android.content.ActivityNotFoundException
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.graphics.Typeface
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.net.Uri
|
||||
import android.telephony.SubscriptionManager
|
||||
import android.util.TypedValue
|
||||
import android.view.Menu
|
||||
import android.view.View
|
||||
|
|
@ -40,7 +40,12 @@ import com.simplemobiletools.smsmessenger.models.*
|
|||
import kotlinx.android.synthetic.main.item_attachment_image.view.*
|
||||
import kotlinx.android.synthetic.main.item_attachment_vcard.view.*
|
||||
import kotlinx.android.synthetic.main.item_received_message.view.*
|
||||
import kotlinx.android.synthetic.main.item_received_message.view.thread_mesage_attachments_holder
|
||||
import kotlinx.android.synthetic.main.item_received_message.view.thread_message_body
|
||||
import kotlinx.android.synthetic.main.item_received_message.view.thread_message_holder
|
||||
import kotlinx.android.synthetic.main.item_received_message.view.thread_message_play_outline
|
||||
import kotlinx.android.synthetic.main.item_received_unknown_attachment.view.*
|
||||
import kotlinx.android.synthetic.main.item_sent_message.view.*
|
||||
import kotlinx.android.synthetic.main.item_sent_unknown_attachment.view.*
|
||||
import kotlinx.android.synthetic.main.item_thread_date_time.view.*
|
||||
import kotlinx.android.synthetic.main.item_thread_error.view.*
|
||||
|
|
@ -252,29 +257,9 @@ class ThreadAdapter(
|
|||
thread_message_body.beVisibleIf(message.body.isNotEmpty())
|
||||
|
||||
if (message.isReceivedMessage()) {
|
||||
thread_message_sender_photo.beVisible()
|
||||
thread_message_sender_photo.setOnClickListener {
|
||||
val contact = message.participants.first()
|
||||
context.getContactFromAddress(contact.phoneNumbers.first().normalizedNumber) {
|
||||
if (it != null) {
|
||||
(activity as ThreadActivity).startContactDetailsIntent(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
thread_message_body.setTextColor(textColor)
|
||||
thread_message_body.setLinkTextColor(context.getProperPrimaryColor())
|
||||
|
||||
if (!activity.isFinishing && !activity.isDestroyed) {
|
||||
SimpleContactsHelper(context).loadContactImage(message.senderPhotoUri, thread_message_sender_photo, message.senderName)
|
||||
}
|
||||
setupReceivedMessageView(view, message)
|
||||
} else {
|
||||
thread_message_sender_photo?.beGone()
|
||||
val background = context.getProperPrimaryColor()
|
||||
thread_message_body.background.applyColorFilter(background)
|
||||
|
||||
val contrastColor = background.getContrastColor()
|
||||
thread_message_body.setTextColor(contrastColor)
|
||||
thread_message_body.setLinkTextColor(contrastColor)
|
||||
setupSentMessageView(view, message)
|
||||
}
|
||||
|
||||
thread_message_body.setOnLongClickListener {
|
||||
|
|
@ -304,6 +289,55 @@ class ThreadAdapter(
|
|||
}
|
||||
}
|
||||
|
||||
private fun setupReceivedMessageView(view: View, message: Message) {
|
||||
view.apply {
|
||||
thread_message_sender_photo.beVisible()
|
||||
thread_message_sender_photo.setOnClickListener {
|
||||
val contact = message.participants.first()
|
||||
context.getContactFromAddress(contact.phoneNumbers.first().normalizedNumber) {
|
||||
if (it != null) {
|
||||
(activity as ThreadActivity).startContactDetailsIntent(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
thread_message_body.setTextColor(textColor)
|
||||
thread_message_body.setLinkTextColor(context.getProperPrimaryColor())
|
||||
|
||||
if (!activity.isFinishing && !activity.isDestroyed) {
|
||||
SimpleContactsHelper(context).loadContactImage(message.senderPhotoUri, thread_message_sender_photo, message.senderName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupSentMessageView(view: View, message: Message) {
|
||||
view.apply {
|
||||
thread_message_sender_photo?.beGone()
|
||||
val background = context.getProperPrimaryColor()
|
||||
thread_message_body.background.applyColorFilter(background)
|
||||
|
||||
val contrastColor = background.getContrastColor()
|
||||
thread_message_body.setTextColor(contrastColor)
|
||||
thread_message_body.setLinkTextColor(contrastColor)
|
||||
|
||||
val padding = thread_message_body.paddingStart
|
||||
if (message.isScheduled) {
|
||||
thread_message_scheduled_icon.beVisible()
|
||||
thread_message_scheduled_icon.applyColorFilter(contrastColor)
|
||||
|
||||
thread_message_scheduled_icon.onGlobalLayout {
|
||||
val rightPadding = padding + thread_message_scheduled_icon.measuredWidth
|
||||
thread_message_body.setPadding(padding, padding, rightPadding, padding)
|
||||
}
|
||||
thread_message_body.typeface = Typeface.create(Typeface.DEFAULT, Typeface.ITALIC)
|
||||
} else {
|
||||
thread_message_scheduled_icon.beGone()
|
||||
|
||||
thread_message_body.setPadding(padding, padding, padding, padding)
|
||||
thread_message_body.typeface = Typeface.create(Typeface.DEFAULT, Typeface.NORMAL)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupImageView(holder: ViewHolder, parent: View, message: Message, attachment: Attachment) {
|
||||
val mimetype = attachment.mimetype
|
||||
val uri = attachment.getUri()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue