Add avatar to my story row and wire in badges.
This commit is contained in:
parent
0b1a93d3e6
commit
bf897d10d2
3 changed files with 36 additions and 2 deletions
|
@ -2,7 +2,10 @@ package org.thoughtcrime.securesms.stories.landing
|
|||
|
||||
import android.view.View
|
||||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.avatar.view.AvatarView
|
||||
import org.thoughtcrime.securesms.badges.BadgeImageView
|
||||
import org.thoughtcrime.securesms.components.settings.PreferenceModel
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.util.adapter.mapping.LayoutFactory
|
||||
import org.thoughtcrime.securesms.util.adapter.mapping.MappingAdapter
|
||||
import org.thoughtcrime.securesms.util.adapter.mapping.MappingViewHolder
|
||||
|
@ -24,8 +27,14 @@ object MyStoriesItem {
|
|||
|
||||
private class ViewHolder(itemView: View) : MappingViewHolder<Model>(itemView) {
|
||||
|
||||
private val avatarView: AvatarView = itemView.findViewById(R.id.avatar)
|
||||
private val badgeView: BadgeImageView = itemView.findViewById(R.id.badge)
|
||||
|
||||
override fun bind(model: Model) {
|
||||
itemView.setOnClickListener { model.onClick() }
|
||||
|
||||
avatarView.displayProfileAvatar(Recipient.self())
|
||||
badgeView.setBadgeFromRecipient(Recipient.self())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import android.widget.TextView
|
|||
import androidx.core.content.ContextCompat
|
||||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.avatar.view.AvatarView
|
||||
import org.thoughtcrime.securesms.badges.BadgeImageView
|
||||
import org.thoughtcrime.securesms.components.ThumbnailView
|
||||
import org.thoughtcrime.securesms.components.settings.PreferenceModel
|
||||
import org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord
|
||||
|
@ -78,6 +79,7 @@ object StoriesLandingItem {
|
|||
private class ViewHolder(itemView: View) : MappingViewHolder<Model>(itemView) {
|
||||
|
||||
private val avatarView: AvatarView = itemView.findViewById(R.id.avatar)
|
||||
private val badgeView: BadgeImageView = itemView.findViewById(R.id.badge)
|
||||
private val storyPreview: ThumbnailView = itemView.findViewById<ThumbnailView>(R.id.story).apply {
|
||||
isClickable = false
|
||||
}
|
||||
|
@ -100,8 +102,10 @@ object StoriesLandingItem {
|
|||
|
||||
if (model.data.storyRecipient.isMyStory) {
|
||||
avatarView.displayProfileAvatar(Recipient.self())
|
||||
badgeView.setBadgeFromRecipient(Recipient.self())
|
||||
} else {
|
||||
avatarView.displayProfileAvatar(model.data.storyRecipient)
|
||||
badgeView.setBadgeFromRecipient(model.data.storyRecipient)
|
||||
}
|
||||
|
||||
val record = model.data.primaryStory.messageRecord as MediaMmsMessageRecord
|
||||
|
|
|
@ -6,16 +6,35 @@
|
|||
android:layout_marginStart="@dimen/dsl_settings_gutter"
|
||||
android:layout_marginEnd="@dimen/dsl_settings_gutter">
|
||||
|
||||
<org.thoughtcrime.securesms.avatar.view.AvatarView
|
||||
android:id="@+id/avatar"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<org.thoughtcrime.securesms.badges.BadgeImageView
|
||||
android:id="@+id/badge"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginStart="32dp"
|
||||
android:layout_marginTop="36dp"
|
||||
app:badge_size="medium"
|
||||
app:layout_constraintStart_toStartOf="@id/avatar"
|
||||
app:layout_constraintTop_toTopOf="@id/avatar" />
|
||||
|
||||
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
|
||||
android:id="@+id/sender"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/StoriesLandingFragment__my_stories"
|
||||
android:textAppearance="@style/TextAppearance.Signal.Body1.Bold"
|
||||
app:layout_constraintBottom_toTopOf="@id/date"
|
||||
app:layout_constraintEnd_toStartOf="@id/story"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/avatar"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_chainStyle="packed" />
|
||||
|
||||
|
@ -23,13 +42,14 @@
|
|||
android:id="@+id/date"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/StoriesLandingFragment__add_a_story"
|
||||
android:textAppearance="@style/TextAppearance.Signal.Body2"
|
||||
android:textColor="@color/signal_text_secondary"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/story"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/avatar"
|
||||
app:layout_constraintTop_toBottomOf="@id/sender" />
|
||||
|
||||
<com.google.android.material.imageview.ShapeableImageView
|
||||
|
@ -38,6 +58,7 @@
|
|||
android:layout_height="84dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:background="@color/signal_background_secondary"
|
||||
android:scaleType="centerInside"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
|
|
Loading…
Add table
Reference in a new issue