show an error at messages that havent been sent
This commit is contained in:
parent
35a2023866
commit
3eb1127c74
|
@ -1,6 +1,7 @@
|
||||||
package com.simplemobiletools.smsmessenger.activities
|
package com.simplemobiletools.smsmessenger.activities
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.provider.Telephony
|
||||||
import android.telephony.SmsManager
|
import android.telephony.SmsManager
|
||||||
import com.simplemobiletools.commons.extensions.applyColorFilter
|
import com.simplemobiletools.commons.extensions.applyColorFilter
|
||||||
import com.simplemobiletools.commons.extensions.onTextChangeListener
|
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_NAME
|
||||||
import com.simplemobiletools.smsmessenger.helpers.THREAD_NUMBER
|
import com.simplemobiletools.smsmessenger.helpers.THREAD_NUMBER
|
||||||
import com.simplemobiletools.smsmessenger.models.ThreadDateTime
|
import com.simplemobiletools.smsmessenger.models.ThreadDateTime
|
||||||
|
import com.simplemobiletools.smsmessenger.models.ThreadError
|
||||||
import com.simplemobiletools.smsmessenger.models.ThreadItem
|
import com.simplemobiletools.smsmessenger.models.ThreadItem
|
||||||
import kotlinx.android.synthetic.main.activity_thread.*
|
import kotlinx.android.synthetic.main.activity_thread.*
|
||||||
|
|
||||||
|
@ -67,6 +69,10 @@ class ThreadActivity : SimpleActivity() {
|
||||||
prevDateTime = it.date
|
prevDateTime = it.date
|
||||||
}
|
}
|
||||||
items.add(it)
|
items.add(it)
|
||||||
|
|
||||||
|
if (it.type == Telephony.Sms.MESSAGE_TYPE_FAILED) {
|
||||||
|
items.add(ThreadError(it.id))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return items
|
return items
|
||||||
|
|
|
@ -12,8 +12,10 @@ import com.simplemobiletools.smsmessenger.activities.SimpleActivity
|
||||||
import com.simplemobiletools.smsmessenger.helpers.THREAD_DATE_TIME
|
import com.simplemobiletools.smsmessenger.helpers.THREAD_DATE_TIME
|
||||||
import com.simplemobiletools.smsmessenger.helpers.THREAD_RECEIVED_MESSAGE
|
import com.simplemobiletools.smsmessenger.helpers.THREAD_RECEIVED_MESSAGE
|
||||||
import com.simplemobiletools.smsmessenger.helpers.THREAD_SENT_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.Message
|
||||||
import com.simplemobiletools.smsmessenger.models.ThreadDateTime
|
import com.simplemobiletools.smsmessenger.models.ThreadDateTime
|
||||||
|
import com.simplemobiletools.smsmessenger.models.ThreadError
|
||||||
import com.simplemobiletools.smsmessenger.models.ThreadItem
|
import com.simplemobiletools.smsmessenger.models.ThreadItem
|
||||||
import kotlinx.android.synthetic.main.item_received_message.view.*
|
import kotlinx.android.synthetic.main.item_received_message.view.*
|
||||||
import kotlinx.android.synthetic.main.item_thread_date_time.view.*
|
import kotlinx.android.synthetic.main.item_thread_date_time.view.*
|
||||||
|
@ -59,6 +61,7 @@ class ThreadAdapter(
|
||||||
val layout = when (viewType) {
|
val layout = when (viewType) {
|
||||||
THREAD_DATE_TIME -> R.layout.item_thread_date_time
|
THREAD_DATE_TIME -> R.layout.item_thread_date_time
|
||||||
THREAD_RECEIVED_MESSAGE -> R.layout.item_received_message
|
THREAD_RECEIVED_MESSAGE -> R.layout.item_received_message
|
||||||
|
THREAD_SENT_MESSAGE_ERROR -> R.layout.item_thread_error
|
||||||
else -> R.layout.item_sent_message
|
else -> R.layout.item_sent_message
|
||||||
}
|
}
|
||||||
return createViewHolder(layout, parent)
|
return createViewHolder(layout, parent)
|
||||||
|
@ -69,7 +72,7 @@ class ThreadAdapter(
|
||||||
holder.bindView(item, true, item is Message) { itemView, layoutPosition ->
|
holder.bindView(item, true, item is Message) { itemView, layoutPosition ->
|
||||||
if (item is ThreadDateTime) {
|
if (item is ThreadDateTime) {
|
||||||
setupDateTime(itemView, item)
|
setupDateTime(itemView, item)
|
||||||
} else {
|
} else if (item !is ThreadError) {
|
||||||
setupView(itemView, item as Message)
|
setupView(itemView, item as Message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,6 +86,7 @@ class ThreadAdapter(
|
||||||
return when {
|
return when {
|
||||||
item is ThreadDateTime -> THREAD_DATE_TIME
|
item is ThreadDateTime -> THREAD_DATE_TIME
|
||||||
(messages[position] as? Message)?.isReceivedMessage() == true -> THREAD_RECEIVED_MESSAGE
|
(messages[position] as? Message)?.isReceivedMessage() == true -> THREAD_RECEIVED_MESSAGE
|
||||||
|
item is ThreadError -> THREAD_SENT_MESSAGE_ERROR
|
||||||
else -> THREAD_SENT_MESSAGE
|
else -> THREAD_SENT_MESSAGE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,3 +8,4 @@ const val THREAD_NUMBER = "thread_number"
|
||||||
const val THREAD_DATE_TIME = 1
|
const val THREAD_DATE_TIME = 1
|
||||||
const val THREAD_RECEIVED_MESSAGE = 2
|
const val THREAD_RECEIVED_MESSAGE = 2
|
||||||
const val THREAD_SENT_MESSAGE = 3
|
const val THREAD_SENT_MESSAGE = 3
|
||||||
|
const val THREAD_SENT_MESSAGE_ERROR = 4
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
package com.simplemobiletools.smsmessenger.models
|
||||||
|
|
||||||
|
data class ThreadError(val messageID: Int) : ThreadItem()
|
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/thread_date_time"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="end"
|
||||||
|
android:text="@string/message_not_sent"
|
||||||
|
android:textColor="@color/theme_dark_red_primary_color"
|
||||||
|
android:textSize="@dimen/normal_text_size" />
|
|
@ -2,4 +2,5 @@
|
||||||
<string name="app_name">Simple SMS Messenger</string>
|
<string name="app_name">Simple SMS Messenger</string>
|
||||||
<string name="app_launcher_name">SMS Messenger</string>
|
<string name="app_launcher_name">SMS Messenger</string>
|
||||||
<string name="type_a_message">Type a message…</string>
|
<string name="type_a_message">Type a message…</string>
|
||||||
|
<string name="message_not_sent">Message has not been sent.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in New Issue