mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 11:38:51 +01:00
Fix storage of SMS delivery status
This commit is contained in:
@@ -4,7 +4,6 @@ import android.content.ContentUris
|
||||
import android.net.Uri
|
||||
import android.provider.Telephony.*
|
||||
import io.realm.RealmObject
|
||||
import io.realm.annotations.Ignore
|
||||
import io.realm.annotations.PrimaryKey
|
||||
|
||||
open class Message : RealmObject() {
|
||||
@@ -24,19 +23,23 @@ open class Message : RealmObject() {
|
||||
var read: Boolean = false
|
||||
var locked: Boolean = false
|
||||
|
||||
@Ignore var deliveryStatus: DeliveryStatus = DeliveryStatus.NONE
|
||||
var deliveryStatusString: String = DeliveryStatus.NONE.toString()
|
||||
var deliveryStatus: DeliveryStatus
|
||||
get() = DeliveryStatus.valueOf(deliveryStatusString)
|
||||
var deliveryStatusString: String = "NONE"
|
||||
get() = deliveryStatus.toString()
|
||||
set(value) {
|
||||
deliveryStatusString = value.toString()
|
||||
}
|
||||
|
||||
// SMS only
|
||||
var errorCode: Int = 0
|
||||
|
||||
// MMS only
|
||||
@Ignore var attachmentType: AttachmentType = AttachmentType.NOT_LOADED
|
||||
var attachmentTypeString: String = AttachmentType.NOT_LOADED.toString()
|
||||
var attachmentType: AttachmentType
|
||||
get() = AttachmentType.valueOf(attachmentTypeString)
|
||||
var attachmentTypeString: String = "NOT_LOADED"
|
||||
get() = attachmentType.toString()
|
||||
set(value) {
|
||||
attachmentTypeString = value.toString()
|
||||
}
|
||||
|
||||
var mmsDeliveryStatusString: String = ""
|
||||
var readReportString: String = ""
|
||||
@@ -76,6 +79,12 @@ open class Message : RealmObject() {
|
||||
return !isFailedMessage() && isOutgoingMessage()
|
||||
}
|
||||
|
||||
fun isDelivered(): Boolean {
|
||||
val isDeliveredMms = false // TODO
|
||||
val isDeliveredSms = deliveryStatus == DeliveryStatus.RECEIVED
|
||||
return isDeliveredMms || isDeliveredSms
|
||||
}
|
||||
|
||||
fun isFailedMessage(): Boolean {
|
||||
val isFailedMms = isMms() && errorType >= MmsSms.ERR_TYPE_GENERIC_PERMANENT
|
||||
val isFailedSms = isSms() && boxId == Sms.MESSAGE_TYPE_FAILED
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.moez.QKSMS.common.util.DateFormatter
|
||||
import com.moez.QKSMS.common.util.extensions.dpToPx
|
||||
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
||||
import com.moez.QKSMS.common.util.extensions.setPadding
|
||||
import com.moez.QKSMS.common.util.extensions.setVisible
|
||||
import com.moez.QKSMS.data.model.Contact
|
||||
import com.moez.QKSMS.data.model.Message
|
||||
import com.moez.QKSMS.data.model.PhoneNumber
|
||||
@@ -83,16 +84,13 @@ class MessagesAdapter @Inject constructor(
|
||||
|
||||
bindGrouping(view, position)
|
||||
|
||||
view.status?.visibility = when {
|
||||
message.isSending() || message.isFailedMessage() -> View.VISIBLE
|
||||
else -> View.GONE
|
||||
}
|
||||
|
||||
view.status?.text = when {
|
||||
message.isSending() -> "Sending..."
|
||||
message.isFailedMessage() -> "Failed to send. Tap to try again"
|
||||
message.isSending() -> context.getString(R.string.message_status_sending)
|
||||
message.isDelivered() -> context.getString(R.string.message_status_delivered)
|
||||
message.isFailedMessage() -> context.getString(R.string.message_status_failed)
|
||||
else -> null
|
||||
}
|
||||
view.status?.setVisible(!view.status?.text.isNullOrBlank())
|
||||
|
||||
view.body.text = message.body
|
||||
view.timestamp.text = dateFormatter.getMessageTimestamp(message.date)
|
||||
|
||||
Reference in New Issue
Block a user