diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/ThreadActivity.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/ThreadActivity.kt index c87360c0..b6c5e63f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/ThreadActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/ThreadActivity.kt @@ -1,6 +1,7 @@ package com.simplemobiletools.smsmessenger.activities import android.os.Bundle +import android.provider.Telephony import android.telephony.SmsManager import com.simplemobiletools.commons.extensions.applyColorFilter import com.simplemobiletools.commons.extensions.onTextChangeListener @@ -13,6 +14,7 @@ import com.simplemobiletools.smsmessenger.helpers.THREAD_ID import com.simplemobiletools.smsmessenger.helpers.THREAD_NAME import com.simplemobiletools.smsmessenger.helpers.THREAD_NUMBER import com.simplemobiletools.smsmessenger.models.ThreadDateTime +import com.simplemobiletools.smsmessenger.models.ThreadError import com.simplemobiletools.smsmessenger.models.ThreadItem import kotlinx.android.synthetic.main.activity_thread.* @@ -67,6 +69,10 @@ class ThreadActivity : SimpleActivity() { prevDateTime = it.date } items.add(it) + + if (it.type == Telephony.Sms.MESSAGE_TYPE_FAILED) { + items.add(ThreadError(it.id)) + } } return items diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/adapters/ThreadAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/adapters/ThreadAdapter.kt index 678416ae..4848c857 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/adapters/ThreadAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/adapters/ThreadAdapter.kt @@ -12,8 +12,10 @@ import com.simplemobiletools.smsmessenger.activities.SimpleActivity import com.simplemobiletools.smsmessenger.helpers.THREAD_DATE_TIME import com.simplemobiletools.smsmessenger.helpers.THREAD_RECEIVED_MESSAGE import com.simplemobiletools.smsmessenger.helpers.THREAD_SENT_MESSAGE +import com.simplemobiletools.smsmessenger.helpers.THREAD_SENT_MESSAGE_ERROR import com.simplemobiletools.smsmessenger.models.Message import com.simplemobiletools.smsmessenger.models.ThreadDateTime +import com.simplemobiletools.smsmessenger.models.ThreadError import com.simplemobiletools.smsmessenger.models.ThreadItem import kotlinx.android.synthetic.main.item_received_message.view.* import kotlinx.android.synthetic.main.item_thread_date_time.view.* @@ -59,6 +61,7 @@ class ThreadAdapter( val layout = when (viewType) { 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 else -> R.layout.item_sent_message } return createViewHolder(layout, parent) @@ -69,7 +72,7 @@ class ThreadAdapter( holder.bindView(item, true, item is Message) { itemView, layoutPosition -> if (item is ThreadDateTime) { setupDateTime(itemView, item) - } else { + } else if (item !is ThreadError) { setupView(itemView, item as Message) } } @@ -83,6 +86,7 @@ class ThreadAdapter( return when { item is ThreadDateTime -> THREAD_DATE_TIME (messages[position] as? Message)?.isReceivedMessage() == true -> THREAD_RECEIVED_MESSAGE + item is ThreadError -> THREAD_SENT_MESSAGE_ERROR else -> THREAD_SENT_MESSAGE } } diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/helpers/Constants.kt index 1300bebb..4da4f345 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/helpers/Constants.kt @@ -8,3 +8,4 @@ const val THREAD_NUMBER = "thread_number" const val THREAD_DATE_TIME = 1 const val THREAD_RECEIVED_MESSAGE = 2 const val THREAD_SENT_MESSAGE = 3 +const val THREAD_SENT_MESSAGE_ERROR = 4 diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/models/ThreadError.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/models/ThreadError.kt new file mode 100644 index 00000000..69df786f --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/models/ThreadError.kt @@ -0,0 +1,3 @@ +package com.simplemobiletools.smsmessenger.models + +data class ThreadError(val messageID: Int) : ThreadItem() diff --git a/app/src/main/res/layout/item_thread_error.xml b/app/src/main/res/layout/item_thread_error.xml new file mode 100644 index 00000000..dcbebf95 --- /dev/null +++ b/app/src/main/res/layout/item_thread_error.xml @@ -0,0 +1,9 @@ + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 20922a0a..81c7ed89 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2,4 +2,5 @@ Simple SMS Messenger SMS Messenger Type a messageā€¦ + Message has not been sent.