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