Reactions: more refinements
This commit is contained in:
parent
911ee97122
commit
0244fea222
|
@ -61,7 +61,8 @@
|
|||
<dimen name="chat_bubble_fixed_size">300dp</dimen>
|
||||
<dimen name="chat_bubble_corner_radius">12dp</dimen>
|
||||
|
||||
<dimen name="chat_reaction_min_height">30dp</dimen>
|
||||
<dimen name="chat_reaction_min_height">28dp</dimen>
|
||||
<dimen name="chat_reaction_min_width">40dp</dimen>
|
||||
|
||||
<!-- Onboarding -->
|
||||
<item name="ftue_auth_gutter_start_percent" format="float" type="dimen">0.05</item>
|
||||
|
|
|
@ -50,7 +50,7 @@ import javax.inject.Inject
|
|||
class MessageInformationDataFactory @Inject constructor(private val session: Session,
|
||||
private val dateFormatter: VectorDateFormatter,
|
||||
private val messageLayoutFactory: TimelineMessageLayoutFactory,
|
||||
private val reactionListFactory: ReactionsSummaryFactory) {
|
||||
private val reactionsSummaryFactory: ReactionsSummaryFactory) {
|
||||
|
||||
fun create(params: TimelineItemFactoryParams): MessageInformationData {
|
||||
val event = params.event
|
||||
|
@ -93,7 +93,7 @@ class MessageInformationDataFactory @Inject constructor(private val session: Ses
|
|||
avatarUrl = event.senderInfo.avatarUrl,
|
||||
memberName = event.senderInfo.disambiguatedDisplayName,
|
||||
messageLayout = messageLayout,
|
||||
reactionsSummary = reactionListFactory.create(event, params.callback),
|
||||
reactionsSummary = reactionsSummaryFactory.create(event, params.callback),
|
||||
pollResponseAggregatedSummary = event.annotations?.pollResponseSummary?.let {
|
||||
PollResponseData(
|
||||
myVote = it.aggregatedContent?.myVote,
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
package im.vector.app.features.home.room.detail.timeline.item
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
@ -30,6 +29,7 @@ import im.vector.app.R
|
|||
import im.vector.app.core.epoxy.ClickListener
|
||||
import im.vector.app.core.epoxy.onClick
|
||||
import im.vector.app.core.ui.views.ShieldImageView
|
||||
import im.vector.app.core.utils.DimensionConverter
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import im.vector.app.features.home.room.detail.timeline.MessageColorProvider
|
||||
import im.vector.app.features.home.room.detail.timeline.TimelineEventController
|
||||
|
@ -38,6 +38,9 @@ import im.vector.app.features.reactions.widget.ReactionButton
|
|||
import org.matrix.android.sdk.api.crypto.RoomEncryptionTrustLevel
|
||||
import org.matrix.android.sdk.api.session.room.send.SendState
|
||||
|
||||
|
||||
private const val MAX_REACTIONS_TO_SHOW = 8
|
||||
|
||||
/**
|
||||
* Base timeline item with reactions and read receipts.
|
||||
* Manages associated click listeners and send status.
|
||||
|
@ -99,7 +102,7 @@ abstract class AbsBaseMessageItem<H : AbsBaseMessageItem.Holder> : BaseEventItem
|
|||
val reactionsToShow = if (reactionsSummary.showAll) {
|
||||
reactions
|
||||
} else {
|
||||
reactions.take(8)
|
||||
reactions.take(MAX_REACTIONS_TO_SHOW)
|
||||
}
|
||||
reactionsToShow.forEach { reaction ->
|
||||
val reactionButton = ReactionButton(holder.view.context)
|
||||
|
@ -111,19 +114,19 @@ abstract class AbsBaseMessageItem<H : AbsBaseMessageItem.Holder> : BaseEventItem
|
|||
reactionButton.isEnabled = reaction.synced
|
||||
holder.reactionsContainer.addView(reactionButton)
|
||||
}
|
||||
if (reactions.count() > 8) {
|
||||
val showReactionsTextView = createReactionTextView(holder.view.context)
|
||||
if (reactions.count() > MAX_REACTIONS_TO_SHOW) {
|
||||
val showReactionsTextView = createReactionTextView(holder, 6)
|
||||
if (reactionsSummary.showAll) {
|
||||
showReactionsTextView.setText(R.string.message_reaction_show_less)
|
||||
showReactionsTextView.onClick { reactionsSummary.onShowLessClicked() }
|
||||
} else {
|
||||
val moreCount = reactions.count() - 8
|
||||
val moreCount = reactions.count() - MAX_REACTIONS_TO_SHOW
|
||||
showReactionsTextView.text = holder.view.resources.getString(R.string.message_reaction_show_more, moreCount)
|
||||
showReactionsTextView.onClick { reactionsSummary.onShowMoreClicked() }
|
||||
}
|
||||
holder.reactionsContainer.addView(showReactionsTextView)
|
||||
}
|
||||
val addMoreReactionsTextView = createReactionTextView(holder.view.context)
|
||||
val addMoreReactionsTextView = createReactionTextView(holder, 14)
|
||||
addMoreReactionsTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_add_reaction_small, 0, 0, 0)
|
||||
addMoreReactionsTextView.onClick { reactionsSummary.onAddMoreClicked() }
|
||||
holder.reactionsContainer.addView(addMoreReactionsTextView)
|
||||
|
@ -131,13 +134,14 @@ abstract class AbsBaseMessageItem<H : AbsBaseMessageItem.Holder> : BaseEventItem
|
|||
}
|
||||
}
|
||||
|
||||
private fun createReactionTextView(context: Context): TextView {
|
||||
return TextView(context).apply {
|
||||
private fun createReactionTextView(holder: H, horizontalPaddingDp: Int): TextView {
|
||||
return TextView(holder.view.context).apply {
|
||||
textSize = 10f
|
||||
gravity = Gravity.CENTER
|
||||
minimumHeight = resources.getDimensionPixelSize(R.dimen.chat_reaction_min_height)
|
||||
minimumWidth = resources.getDimensionPixelSize(R.dimen.chat_reaction_min_width)
|
||||
background = getDrawable(context, R.drawable.reaction_rounded_rect_shape_off)
|
||||
val padding = resources.getDimensionPixelSize(R.dimen.layout_horizontal_margin)
|
||||
val padding = holder.dimensionConverter.dpToPx(horizontalPaddingDp)
|
||||
setPadding(padding, 0, padding, 0)
|
||||
}
|
||||
}
|
||||
|
@ -155,6 +159,9 @@ abstract class AbsBaseMessageItem<H : AbsBaseMessageItem.Holder> : BaseEventItem
|
|||
}
|
||||
|
||||
abstract class Holder(@IdRes stubId: Int) : BaseEventItem.BaseHolder(stubId) {
|
||||
val dimensionConverter by lazy {
|
||||
DimensionConverter(view.resources)
|
||||
}
|
||||
val reactionsContainer by bind<ViewGroup>(R.id.reactionsContainer)
|
||||
val e2EDecorationView by bind<ShieldImageView>(R.id.messageE2EDecoration)
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@ class ReactionButton @JvmOverloads constructor(context: Context,
|
|||
inflate(context, R.layout.reaction_button, this)
|
||||
orientation = HORIZONTAL
|
||||
minimumHeight = resources.getDimensionPixelSize(R.dimen.chat_reaction_min_height)
|
||||
minimumWidth = resources.getDimensionPixelSize(R.dimen.chat_reaction_min_width)
|
||||
gravity = Gravity.CENTER
|
||||
layoutDirection = View.LAYOUT_DIRECTION_LOCALE
|
||||
views = ReactionButtonBinding.bind(this)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<size
|
||||
android:width="8dp"
|
||||
android:height="8dp" />
|
||||
android:width="4dp"
|
||||
android:height="4dp" />
|
||||
<solid android:color="#00000000" />
|
||||
</shape>
|
|
@ -3,11 +3,11 @@
|
|||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="26dp"
|
||||
android:layout_height="@dimen/chat_reaction_min_height"
|
||||
android:background="@drawable/reaction_rounded_rect_shape"
|
||||
android:clipChildren="false"
|
||||
android:gravity="center"
|
||||
android:minWidth="44dp"
|
||||
android:minWidth="@dimen/chat_reaction_min_width"
|
||||
tools:parentTag="android.widget.LinearLayout">
|
||||
|
||||
<!--<View-->
|
||||
|
@ -20,12 +20,11 @@
|
|||
android:id="@+id/reactionText"
|
||||
style="@style/Widget.Vector.TextView.Caption"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="20dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="6dp"
|
||||
android:ellipsize="middle"
|
||||
android:gravity="center"
|
||||
android:maxEms="10"
|
||||
android:minWidth="20dp"
|
||||
android:singleLine="true"
|
||||
android:textColor="@color/emoji_color"
|
||||
tools:text="* Party Parrot Again * 👀" />
|
||||
|
@ -36,7 +35,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="2dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:gravity="center"
|
||||
android:maxLines="1"
|
||||
android:textColor="?vctr_content_secondary"
|
||||
|
|
Loading…
Reference in New Issue