forked from upstream-mirrors/quik
Improved UI for message status
This commit is contained in:
@@ -12,7 +12,7 @@ import com.moez.QKSMS.util.DateFormatter
|
||||
import com.moez.QKSMS.util.ThemeManager
|
||||
import com.moez.QKSMS.util.extensions.dpToPx
|
||||
import com.moez.QKSMS.util.extensions.setBackgroundTint
|
||||
import com.moez.QKSMS.util.extensions.setMargins
|
||||
import com.moez.QKSMS.util.extensions.setPadding
|
||||
import io.realm.OrderedRealmCollection
|
||||
import io.realm.RealmRecyclerViewAdapter
|
||||
import timber.log.Timber
|
||||
@@ -63,10 +63,14 @@ class MessageAdapter(data: OrderedRealmCollection<Message>?) : RealmRecyclerView
|
||||
|
||||
bindGrouping(viewHolder, position)
|
||||
|
||||
viewHolder.status?.visibility = when {
|
||||
message.isSending() || message.isFailedMessage() -> View.VISIBLE
|
||||
else -> View.GONE
|
||||
}
|
||||
viewHolder.status?.text = when {
|
||||
message.isSending() -> "..."
|
||||
message.isFailedMessage() -> "fail"
|
||||
else -> "sent"
|
||||
message.isSending() -> "Sending..."
|
||||
message.isFailedMessage() -> "Failed to send. Tap to try again"
|
||||
else -> null
|
||||
}
|
||||
|
||||
viewHolder.avatar?.apply { contact = Contact() }
|
||||
@@ -88,22 +92,22 @@ class MessageAdapter(data: OrderedRealmCollection<Message>?) : RealmRecyclerView
|
||||
|
||||
when {
|
||||
!canGroupWithPrevious && canGroupWithNext -> {
|
||||
viewHolder.message.setMargins(bottom = 2.dpToPx(context))
|
||||
viewHolder.itemView.setPadding(bottom = 2.dpToPx(context))
|
||||
viewHolder.body.setBackgroundResource(if (sent) R.drawable.message_out_first else R.drawable.message_in_first)
|
||||
viewHolder.avatar?.visibility = View.INVISIBLE
|
||||
}
|
||||
canGroupWithPrevious && canGroupWithNext -> {
|
||||
viewHolder.message.setMargins(bottom = 2.dpToPx(context))
|
||||
viewHolder.itemView.setPadding(bottom = 2.dpToPx(context))
|
||||
viewHolder.body.setBackgroundResource(if (sent) R.drawable.message_out_middle else R.drawable.message_in_middle)
|
||||
viewHolder.avatar?.visibility = View.INVISIBLE
|
||||
}
|
||||
canGroupWithPrevious && !canGroupWithNext -> {
|
||||
viewHolder.message.setMargins(bottom = 16.dpToPx(context))
|
||||
viewHolder.itemView.setPadding(bottom = 16.dpToPx(context))
|
||||
viewHolder.body.setBackgroundResource(if (sent) R.drawable.message_out_last else R.drawable.message_in_last)
|
||||
viewHolder.avatar?.visibility = View.VISIBLE
|
||||
}
|
||||
else -> {
|
||||
viewHolder.message.setMargins(bottom = 16.dpToPx(context))
|
||||
viewHolder.itemView.setPadding(bottom = 16.dpToPx(context))
|
||||
viewHolder.body.setBackgroundResource(R.drawable.message_only)
|
||||
viewHolder.avatar?.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
@@ -23,4 +23,8 @@ fun View.setMargins(left: Int? = null, top: Int? = null, right: Int? = null, bot
|
||||
bottom ?: lp.rightMargin)
|
||||
|
||||
layoutParams = lp
|
||||
}
|
||||
|
||||
fun View.setPadding(left: Int? = null, top: Int? = null, right: Int? = null, bottom: Int? = null) {
|
||||
setPadding(left ?: paddingLeft, top ?: paddingTop, right ?: paddingRight, bottom ?: paddingBottom)
|
||||
}
|
||||
@@ -4,7 +4,8 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:orientation="vertical">
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="16dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/timestamp"
|
||||
@@ -20,7 +21,6 @@
|
||||
android:id="@+id/message"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:gravity="start|bottom"
|
||||
android:orientation="horizontal"
|
||||
android:paddingEnd="60dp"
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:orientation="vertical">
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="16dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/timestamp"
|
||||
@@ -20,7 +21,6 @@
|
||||
android:id="@+id/message"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:gravity="end|bottom"
|
||||
android:paddingEnd="12dp"
|
||||
android:paddingStart="60dp">
|
||||
@@ -57,8 +57,9 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="right"
|
||||
android:layout_marginRight="24dp"
|
||||
android:layout_marginRight="12dp"
|
||||
android:paddingTop="4dp"
|
||||
android:textColor="@color/textTertiary"
|
||||
tools:text="Sending" />
|
||||
tools:text="Sending..." />
|
||||
|
||||
</LinearLayout>
|
||||
Reference in New Issue
Block a user