forked from upstream-mirrors/quik
Add timestamps to conversations
This commit is contained in:
@@ -9,6 +9,7 @@ import com.moez.QKSMS.dagger.AppComponentManager
|
||||
import com.moez.QKSMS.data.model.Message
|
||||
import com.moez.QKSMS.data.repository.MessageRepository
|
||||
import com.moez.QKSMS.ui.messages.MessageListActivity
|
||||
import com.moez.QKSMS.util.DateFormatter
|
||||
import com.moez.QKSMS.util.extensions.getColorCompat
|
||||
import io.realm.OrderedRealmCollection
|
||||
import io.realm.RealmList
|
||||
@@ -19,6 +20,7 @@ class ConversationAdapter(data: OrderedRealmCollection<Message>?) : RealmRecycle
|
||||
|
||||
@Inject lateinit var context: Context
|
||||
@Inject lateinit var messageRepo: MessageRepository
|
||||
@Inject lateinit var dateFormatter: DateFormatter
|
||||
|
||||
init {
|
||||
AppComponentManager.appComponent.inject(this)
|
||||
@@ -38,9 +40,14 @@ class ConversationAdapter(data: OrderedRealmCollection<Message>?) : RealmRecycle
|
||||
.putExtra("threadId", message.threadId))
|
||||
}
|
||||
|
||||
val textColor = context.getColorCompat(if (message.read) R.color.textTertiary else R.color.textPrimary)
|
||||
|
||||
viewHolder.avatar.contacts = conversation?.contacts ?: RealmList()
|
||||
viewHolder.title.text = conversation?.getTitle()
|
||||
viewHolder.date.text = dateFormatter.getMessageTimestamp(message.date)
|
||||
viewHolder.date.setTextColor(textColor)
|
||||
viewHolder.snippet.text = message.body
|
||||
viewHolder.snippet.setTextColor(context.getColorCompat(if (message.read) R.color.textTertiary else R.color.textPrimary))
|
||||
viewHolder.snippet.setTextColor(textColor)
|
||||
viewHolder.snippet.maxLines = if (message.read) 1 else 3
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ class ConversationViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
|
||||
val avatar: GroupAvatarView = view.findViewById(R.id.avatars)
|
||||
val title: TextView = view.findViewById(R.id.title)
|
||||
val date: TextView = view.findViewById(R.id.date)
|
||||
val snippet: TextView = view.findViewById(R.id.snippet)
|
||||
|
||||
}
|
||||
|
||||
@@ -23,18 +23,34 @@
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
style="@style/TextPrimary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
tools:text="Moez Bhatti" />
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
style="@style/TextPrimary"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_weight="1"
|
||||
tools:text="Moez Bhatti" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/date"
|
||||
style="@style/TextTertiary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="Oct 11" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/snippet"
|
||||
style="@style/TextSecondary"
|
||||
android:layout_width="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="2dp"
|
||||
|
||||
@@ -21,4 +21,9 @@
|
||||
<item name="android:textSize">14sp</item>
|
||||
</style>
|
||||
|
||||
<style name="TextTertiary">
|
||||
<item name="android:textColor">@color/textTertiary</item>
|
||||
<item name="android:textSize">12sp</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user