Commit 15a317a4 authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Add drawables / updates the chat list UI.

parent 094c88d4
...@@ -108,7 +108,7 @@ object DrawableHelper { ...@@ -108,7 +108,7 @@ object DrawableHelper {
* @see [UserStatus] * @see [UserStatus]
* @return The user status drawable. * @return The user status drawable.
*/ */
fun getUserStatusDrawable(userStatus: UserStatus, context: Context, getSmallDrawable: Boolean = false): Drawable { fun getUserStatusDrawable(userStatus: UserStatus?, context: Context, getSmallDrawable: Boolean = false): Drawable {
return when (userStatus) { return when (userStatus) {
is UserStatus.Online -> { is UserStatus.Online -> {
getDrawableFromId( getDrawableFromId(
......
...@@ -10,6 +10,7 @@ import android.text.SpannableStringBuilder ...@@ -10,6 +10,7 @@ import android.text.SpannableStringBuilder
import android.text.style.ForegroundColorSpan import android.text.style.ForegroundColorSpan
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView import android.widget.TextView
import chat.rocket.android.R import chat.rocket.android.R
import chat.rocket.android.infrastructure.LocalRepository import chat.rocket.android.infrastructure.LocalRepository
...@@ -50,6 +51,7 @@ class ChatRoomsAdapter(private val context: Context, ...@@ -50,6 +51,7 @@ class ChatRoomsAdapter(private val context: Context,
fun bind(chatRoom: ChatRoom) = with(itemView) { fun bind(chatRoom: ChatRoom) = with(itemView) {
bindAvatar(chatRoom, image_avatar) bindAvatar(chatRoom, image_avatar)
bindName(chatRoom, text_chat_name) bindName(chatRoom, text_chat_name)
bindIcon(chatRoom, image_chat_icon)
bindLastMessageDateTime(chatRoom, text_last_message_date_time) bindLastMessageDateTime(chatRoom, text_last_message_date_time)
bindLastMessage(chatRoom, text_last_message) bindLastMessage(chatRoom, text_last_message)
bindUnreadMessages(chatRoom, text_total_unread_messages) bindUnreadMessages(chatRoom, text_total_unread_messages)
...@@ -81,41 +83,40 @@ class ChatRoomsAdapter(private val context: Context, ...@@ -81,41 +83,40 @@ class ChatRoomsAdapter(private val context: Context,
} }
} }
private fun bindName(chatRoom: ChatRoom, textView: TextView) { private fun bindIcon(chatRoom: ChatRoom, imageView: ImageView) {
textView.textContent = chatRoom.name
val drawable = when (chatRoom.type) { val drawable = when (chatRoom.type) {
is RoomType.Channel -> { is RoomType.Channel -> DrawableHelper.getDrawableFromId(
DrawableHelper.getDrawableFromId(R.drawable.ic_room_channel, context) R.drawable.ic_hashtag_12dp,
} context
is RoomType.PrivateGroup -> { )
DrawableHelper.getDrawableFromId(R.drawable.ic_room_lock, context) is RoomType.PrivateGroup -> DrawableHelper.getDrawableFromId(
} R.drawable.ic_lock_12_dp,
is RoomType.DirectMessage -> { context
val status = chatRoom.status )
if (status == null) { is RoomType.DirectMessage -> DrawableHelper.getUserStatusDrawable(
DrawableHelper.getUserStatusDrawable(UserStatus.Offline(), context, true) chatRoom.status,
} else { context,
DrawableHelper.getUserStatusDrawable(status, context, true) true
} )
}
else -> null else -> null
} }
drawable?.let { drawable?.let {
val wrappedDrawable = DrawableHelper.wrapDrawable(it)
val mutableDrawable = wrappedDrawable.mutate()
val color = when (chatRoom.alert || chatRoom.unread > 0) {
true -> R.color.colorPrimaryText
false -> R.color.colorSecondaryText
}
if (chatRoom.type !is RoomType.DirectMessage) { if (chatRoom.type !is RoomType.DirectMessage) {
DrawableHelper.tintDrawable(mutableDrawable, context, color) DrawableHelper.wrapDrawable(it)
val color = when (chatRoom.alert || chatRoom.unread > 0) {
true -> R.color.colorPrimaryText
false -> R.color.colorSecondaryText
}
DrawableHelper.tintDrawable(it, context, color)
} }
DrawableHelper.compoundDrawable(textView, mutableDrawable) imageView.setImageDrawable(drawable)
} }
} }
private fun bindName(chatRoom: ChatRoom, textView: TextView) {
textView.textContent = chatRoom.name
}
private fun bindLastMessageDateTime(chatRoom: ChatRoom, textView: TextView) { private fun bindLastMessageDateTime(chatRoom: ChatRoom, textView: TextView) {
val lastMessage = chatRoom.lastMessage val lastMessage = chatRoom.lastMessage
if (lastMessage != null) { if (lastMessage != null) {
......
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="12dp"
android:height="12dp"
android:viewportHeight="12"
android:viewportWidth="12">
<path
android:fillColor="#9EA2A8"
android:fillType="evenOdd"
android:pathData="M2.4,0h1.2v12h-1.2z"
android:strokeColor="#00000000"
android:strokeWidth="1" />
<path
android:fillColor="#9EA2A8"
android:fillType="evenOdd"
android:pathData="M0,2.4h12v1.2h-12z"
android:strokeColor="#00000000"
android:strokeWidth="1" />
<path
android:fillColor="#9EA2A8"
android:fillType="evenOdd"
android:pathData="M0,8.4h12v1.2h-12z"
android:strokeColor="#00000000"
android:strokeWidth="1" />
<path
android:fillColor="#9EA2A8"
android:fillType="evenOdd"
android:pathData="M8.4,0h1.2v12h-1.2z"
android:strokeColor="#00000000"
android:strokeWidth="1" />
</vector>
\ No newline at end of file
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="12dp"
android:height="12dp"
android:viewportWidth="12"
android:viewportHeight="12">
<path
android:pathData="M1.5,5.5h9v6h-9z"
android:strokeWidth="1"
android:fillColor="#00000000"
android:strokeColor="#9EA2A8"
android:fillType="evenOdd"/>
<path
android:pathData="M2.5,5.5L9.5,5.5L9.5,4C9.5,2.067 7.933,0.5 6,0.5C4.067,0.5 2.5,2.067 2.5,4L2.5,5.5Z"
android:strokeWidth="1"
android:fillColor="#00000000"
android:strokeColor="#9EA2A8"
android:fillType="evenOdd"/>
</vector>
...@@ -19,16 +19,29 @@ ...@@ -19,16 +19,29 @@
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:roundedCornerRadius="3dp" /> app:roundedCornerRadius="3dp" />
<ImageView
android:id="@+id/image_chat_icon"
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_marginStart="16dp"
android:layout_marginTop="5dp"
app:layout_constraintStart_toEndOf="@id/image_avatar"
app:layout_constraintTop_toTopOf="@+id/image_avatar"
tools:src="@drawable/ic_lock_12_dp" />
<TextView <TextView
android:id="@+id/text_chat_name" android:id="@+id/text_chat_name"
style="@style/ChatRoom.Name.TextView" style="@style/ChatRoom.Name.TextView"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="16dp" android:layout_marginEnd="5dp"
android:drawablePadding="6dp" android:layout_marginStart="8dp"
android:textDirection="locale" android:textDirection="locale"
app:layout_constraintStart_toEndOf="@id/image_avatar" app:layout_constraintBottom_toBottomOf="@+id/image_chat_icon"
tools:text="General" /> app:layout_constraintEnd_toStartOf="@+id/text_last_message_date_time"
app:layout_constraintStart_toEndOf="@id/image_chat_icon"
app:layout_constraintTop_toTopOf="@+id/image_chat_icon"
tools:text="A very very very very big chat room name" />
<TextView <TextView
android:id="@+id/text_last_message_date_time" android:id="@+id/text_last_message_date_time"
...@@ -45,12 +58,13 @@ ...@@ -45,12 +58,13 @@
android:id="@+id/text_last_message" android:id="@+id/text_last_message"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="5dp"
android:layout_marginTop="2dp" android:layout_marginTop="2dp"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="2" android:maxLines="2"
android:textDirection="locale" android:textDirection="locale"
app:layout_constraintEnd_toStartOf="@id/layout_unread_messages_badge" app:layout_constraintEnd_toStartOf="@id/layout_unread_messages_badge"
app:layout_constraintStart_toStartOf="@id/text_chat_name" app:layout_constraintStart_toStartOf="@id/image_chat_icon"
app:layout_constraintTop_toBottomOf="@id/text_chat_name" app:layout_constraintTop_toBottomOf="@id/text_chat_name"
tools:text="You: Type something that is very big and need at least to lines, or maybe even more" /> tools:text="You: Type something that is very big and need at least to lines, or maybe even more" />
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
<dimen name="screen_edge_left_and_right_margins">16dp</dimen> <dimen name="screen_edge_left_and_right_margins">16dp</dimen>
<dimen name="screen_edge_left_and_right_padding">16dp</dimen> <dimen name="screen_edge_left_and_right_padding">16dp</dimen>
<dimen name="chat_item_top_and_bottom_padding">12dp</dimen>
<dimen name="message_item_top_and_bottom_padding">6dp</dimen> <dimen name="message_item_top_and_bottom_padding">6dp</dimen>
<dimen name="member_item_top_and_bottom_padding">6dp</dimen> <dimen name="member_item_top_and_bottom_padding">6dp</dimen>
...@@ -23,6 +22,10 @@ ...@@ -23,6 +22,10 @@
<dimen name="nav_header_height">140dp</dimen> <dimen name="nav_header_height">140dp</dimen>
<!-- ChatRoom -->
<dimen name="chat_item_top_and_bottom_padding">12dp</dimen>
<!-- Emoji --> <!-- Emoji -->
<dimen name="picker_padding_bottom">16dp</dimen> <dimen name="picker_padding_bottom">16dp</dimen>
<dimen name="supposed_keyboard_height">252dp</dimen> <dimen name="supposed_keyboard_height">252dp</dimen>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment