Skip to content

Commit

Permalink
open reactions menu when long click on emojis in message
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Hibbe <[email protected]>
  • Loading branch information
mahibi committed Apr 9, 2022
1 parent 7dd7738 commit 2aec6e7
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,14 @@ class IncomingLocationMessageViewHolder(incomingView: View, payload: Any) : Mess
// geo-location
setLocationDataOnMessageItem(message)

Reaction().showReactions(message, binding.reactions, context!!, false)

Reaction().showReactions(message, binding.reactions, context!!, true)
binding.reactions.reactionsEmojiWrapper.setOnClickListener {
reactionsInterface.onClickReactions(message)
}
binding.reactions.reactionsEmojiWrapper.setOnLongClickListener(View.OnLongClickListener { l: View? ->
reactionsInterface.onLongClickReactions(message)
true
})
}

private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,14 @@ class IncomingVoiceMessageViewHolder(incomingView: View, payload: Any) : Message
}
})

Reaction().showReactions(message, binding.reactions, context!!, false)

Reaction().showReactions(message, binding.reactions, context!!, true)
binding.reactions.reactionsEmojiWrapper.setOnClickListener {
reactionsInterface.onClickReactions(message)
}
binding.reactions.reactionsEmojiWrapper.setOnLongClickListener(View.OnLongClickListener { l: View? ->
reactionsInterface.onLongClickReactions(message)
true
})
}

private fun updateDownloadState(message: ChatMessage) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,14 @@ class MagicIncomingTextMessageViewHolder(itemView: View, payload: Any) : Message

itemView.setTag(MessageSwipeCallback.REPLYABLE_VIEW_TAG, message.isReplyable)

Reaction().showReactions(message, binding.reactions, context!!, false)

Reaction().showReactions(message, binding.reactions, context!!, true)
binding.reactions.reactionsEmojiWrapper.setOnClickListener {
reactionsInterface.onClickReactions(message)
}
binding.reactions.reactionsEmojiWrapper.setOnLongClickListener(View.OnLongClickListener { l: View? ->
reactionsInterface.onLongClickReactions(message)
true
})
}

private fun processAuthor(message: ChatMessage) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,13 @@ class MagicOutcomingTextMessageViewHolder(itemView: View) : OutcomingTextMessage
itemView.setTag(MessageSwipeCallback.REPLYABLE_VIEW_TAG, message.isReplyable)

Reaction().showReactions(message, binding.reactions, context!!, true)

binding.reactions.reactionsEmojiWrapper.setOnClickListener {
reactionsInterface.onClickReactions(message)
}
binding.reactions.reactionsEmojiWrapper.setOnLongClickListener(View.OnLongClickListener { l: View? ->
reactionsInterface.onLongClickReactions(message)
true
})
}

private fun processParentMessage(message: ChatMessage) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,13 @@ public void onBind(ChatMessage message) {

reactionsBinding = getReactionsBinding();
new Reaction().showReactions(message, reactionsBinding, context, false);

reactionsBinding.reactionsEmojiWrapper.setOnClickListener(l -> {
reactionsInterface.onClickReactions(message);
});
reactionsBinding.reactionsEmojiWrapper.setOnLongClickListener(l -> {
reactionsInterface.onLongClickReactions(message);
return true;
});
}

private Drawable getDrawableFromContactDetails(Context context, String base64) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,13 @@ class OutcomingLocationMessageViewHolder(incomingView: View) : MessageHolders
setLocationDataOnMessageItem(message)

Reaction().showReactions(message, binding.reactions, context!!, true)

binding.reactions.reactionsEmojiWrapper.setOnClickListener {
reactionsInterface.onClickReactions(message)
}
binding.reactions.reactionsEmojiWrapper.setOnLongClickListener(View.OnLongClickListener { l: View? ->
reactionsInterface.onLongClickReactions(message)
true
})
}

@SuppressLint("SetJavaScriptEnabled", "ClickableViewAccessibility")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,13 @@ class OutcomingVoiceMessageViewHolder(outcomingView: View) : MessageHolders
binding.checkMark.setContentDescription(readStatusContentDescriptionString)

Reaction().showReactions(message, binding.reactions, context!!, true)

binding.reactions.reactionsEmojiWrapper.setOnClickListener {
reactionsInterface.onClickReactions(message)
}
binding.reactions.reactionsEmojiWrapper.setOnLongClickListener(View.OnLongClickListener { l: View? ->
reactionsInterface.onLongClickReactions(message)
true
})
}

private fun handleResetVoiceMessageState(message: ChatMessage) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ import com.nextcloud.talk.models.json.chat.ChatMessage

interface ReactionsInterface {
fun onClickReactions(chatMessage: ChatMessage)
fun onLongClickReactions(chatMessage: ChatMessage)
}
28 changes: 16 additions & 12 deletions app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -924,18 +924,6 @@ class ChatController(args: Bundle) :
}
}

override fun onClickReactions(chatMessage: ChatMessage) {
activity?.let {
ShowReactionsDialog(
activity!!,
currentConversation,
chatMessage,
conversationUser,
ncApi!!
).show()
}
}

@SuppressLint("LongLogTag")
private fun downloadFileToCache(message: ChatMessage) {
message.isDownloadingVoiceMessage = true
Expand Down Expand Up @@ -2432,6 +2420,22 @@ class ChatController(args: Bundle) :
}
}

override fun onClickReactions(chatMessage: ChatMessage) {
activity?.let {
ShowReactionsDialog(
activity!!,
currentConversation,
chatMessage,
conversationUser,
ncApi!!
).show()
}
}

override fun onLongClickReactions(chatMessage: ChatMessage) {
openMessageActionsDialog(chatMessage)
}

override fun onMessageViewLongClick(view: View?, message: IMessage?) {
openMessageActionsDialog(message)
}
Expand Down

0 comments on commit 2aec6e7

Please sign in to comment.