Merge pull request #677 from benwaffle/show-who-sent-emojis

Implement tapping emoji to see who reacted
This commit is contained in:
octoshrimpy
2026-01-24 08:47:00 -05:00
committed by GitHub
7 changed files with 44 additions and 23 deletions
@@ -190,6 +190,7 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
override val confirmDeleteIntent: Subject<List<Long>> = PublishSubject.create()
override val clearCurrentMessageIntent: Subject<Boolean> = PublishSubject.create()
override val messageLinkAskIntent: Subject<Uri> by lazy { messageAdapter.messageLinkClicks }
override val reactionClickIntent: Subject<Long> by lazy { messageAdapter.reactionClicks }
override val speechRecogniserIntent by lazy { speechToTextIcon.clicks() }
override val shadeIntent by lazy { shadeBackground.clicks() }
override val recordAudioStartStopRecording: Subject<Boolean> = PublishSubject.create()
@@ -757,6 +758,13 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
.show()
}
override fun showReactionsDialog(reactions: List<String>) {
AlertDialog.Builder(this)
.setTitle(R.string.compose_reactions_title)
.setMessage(reactions.joinToString("\n"))
.show()
}
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
menuInflater.inflate(R.menu.compose, menu)
return super.onCreateOptionsMenu(menu)
@@ -77,6 +77,7 @@ interface ComposeView : QkView<ComposeState> {
val confirmDeleteIntent: Observable<List<Long>>
val clearCurrentMessageIntent: Subject<Boolean>
val messageLinkAskIntent: Observable<Uri>
val reactionClickIntent: Subject<Long>
val speechRecogniserIntent: Observable<*>
val shadeIntent: Observable<Unit>
val recordAudioStartStopRecording: Subject<Boolean>
@@ -111,6 +112,7 @@ interface ComposeView : QkView<ComposeState> {
fun showQksmsPlusSnackbar(@StringRes message: Int)
fun showDeleteDialog( messages: List<Long>)
fun showClearCurrentMessageDialog()
fun showReactionsDialog(reactions: List<String>)
fun startSpeechRecognition()
fun focusMessage()
}
@@ -759,6 +759,23 @@ class ComposeViewModel @Inject constructor(
.autoDisposable(view.scope())
.subscribe { view.showMessageLinkAskDialog(it) }
// Show reaction details popup
view.reactionClickIntent
.mapNotNull { messageId -> messageRepo.getMessage(messageId) }
.withLatestFrom(conversation) { message, conv ->
message.emojiReactions.map { reaction ->
val contactName = conv.recipients
.firstOrNull { recipient ->
phoneNumberUtils.compare(recipient.address, reaction.senderAddress)
}
?.getDisplayName()
?: reaction.senderAddress
"${reaction.emoji} $contactName"
}
}
.autoDisposable(view.scope())
.subscribe { reactions -> view.showReactionsDialog(reactions) }
// Set the current conversation
Observables
.combineLatest(
@@ -119,6 +119,7 @@ class MessagesAdapter @Inject constructor(
val sendNowClicks: Subject<Long> = PublishSubject.create()
val resendClicks: Subject<Long> = PublishSubject.create()
val partContextMenuRegistrar: Subject<View> = PublishSubject.create()
val reactionClicks: Subject<Long> = PublishSubject.create()
var data: Pair<Conversation, RealmResults<Message>>? = null
set(value) {
@@ -413,27 +414,15 @@ class MessagesAdapter @Inject constructor(
}
holder.reactionText?.text = reactionText
holder.reactionText?.setOnClickListener { reactionClicks.onNext(message.id) }
reactionsContainer.setVisible(true)
makeRoomForEmojis(holder)
} else {
reactionsContainer.setVisible(false)
holder.reactionText?.setOnClickListener(null)
}
}
}
private fun makeRoomForEmojis(holder: QkViewHolder) {
val paddingBottom = 25.dpToPx(context)
(holder.reactions?.parent?.parent as? ViewGroup)?.let { parent ->
parent.setPadding(
parent.paddingLeft,
parent.paddingTop,
parent.paddingRight,
paddingBottom
)
}
}
private fun bindStatus(
holder: QkViewHolder,
bodyTextTruncated: Boolean,